repo_id stringlengths 15 89 | file_path stringlengths 27 180 | content stringlengths 1 2.23M | __index_level_0__ int64 0 0 |
|---|---|---|---|
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/best_of_n.mdx | # Best of N sampling: Alternative ways to get better model output without RL based fine-tuning
Within the extras module is the `best-of-n` sampler class that serves as an alternative method of generating better model output.
As to how it fares against the RL based fine-tuning, please look in the `examples` directory ... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/lora_tuning_peft.mdx | # Examples of using peft with trl to finetune 8-bit models with Low Rank Adaption (LoRA)
The notebooks and scripts in this examples show how to use Low Rank Adaptation (LoRA) to fine-tune models in a memory efficient manner. Most of PEFT methods supported in peft library but note that some PEFT methods such as Prompt ... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/installation.mdx | # Installation
You can install TRL either from pypi or from source:
## pypi
Install the library with pip:
```bash
pip install trl
```
### Source
You can also install the latest version from source. First clone the repo and then run the installation with `pip`:
```bash
git clone https://github.com/huggingface/trl.gi... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/iterative_sft_trainer.mdx | # Iterative Trainer
Iterative fine-tuning is a training method that enables to perform custom actions (generation and filtering for example) between optimization steps. In TRL we provide an easy-to-use API to fine-tune your models in an iterative way in just a few lines of code.
## Usage
To get started quickly, inst... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/learning_tools.mdx | # Learning Tools (Experimental 🧪)
Using Large Language Models (LLMs) with tools has been a popular topic recently with awesome works such as [ToolFormer](https://arxiv.org/abs/2302.04761) and [ToolBench](https://arxiv.org/pdf/2305.16504.pdf). In TRL, we provide a simple example of how to teach LLM to use tools with r... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/models.mdx | # Models
With the `AutoModelForCausalLMWithValueHead` class TRL supports all decoder model architectures in transformers such as GPT-2, OPT, and GPT-Neo. In addition, with `AutoModelForSeq2SeqLMWithValueHead` you can use encoder-decoder architectures such as T5. TRL also requires reference models which are frozen copi... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/use_model.md | # Use model after training
Once you have trained a model using either the SFTTrainer, PPOTrainer, or DPOTrainer, you will have a fine-tuned model that can be used for text generation. In this section, we'll walk through the process of loading the fine-tuned model and generating text. If you need to run an inference se... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/reward_trainer.mdx | # Reward Modeling
TRL supports custom reward modeling for anyone to perform reward modeling on their dataset and model.
Check out a complete flexible example at [`examples/scripts/reward_modeling.py`](https://github.com/huggingface/trl/tree/main/examples/scripts/reward_modeling.py).
## Expected dataset format
The [... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/index.mdx | <div style="text-align: center">
<img src="https://huggingface.co/datasets/trl-internal-testing/example-images/resolve/main/images/trl_banner_dark.png">
</div>
# TRL - Transformer Reinforcement Learning
TRL is a full stack library where we provide a set of tools to train transformer language models with Reinforcement... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/trainer.mdx | # Trainer
At TRL we support PPO (Proximal Policy Optimisation) with an implementation that largely follows the structure introduced in the paper "Fine-Tuning Language Models from Human Preferences" by D. Ziegler et al. [[paper](https://arxiv.org/pdf/1909.08593.pdf), [code](https://github.com/openai/lm-human-preferenc... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/example_overview.md | # Examples
## Introduction
The examples should work in any of the following settings (with the same script):
- single GPU
- multi GPUS (using PyTorch distributed mode)
- multi GPUS (using DeepSpeed ZeRO-Offload stages 1, 2, & 3)
- fp16 (mixed-precision), fp32 (normal precision), or bf16 (bfloat16 precisi... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/ppo_trainer.mdx | # PPO Trainer
TRL supports the [PPO](https://arxiv.org/abs/1707.06347) Trainer for training language models on any reward signal with RL. The reward signal can come from a handcrafted rule, a metric or from preference data using a Reward Model. For a full example have a look at [`examples/notebooks/gpt2-sentiment.ipyn... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/customization.mdx | # Training customization
TRL is designed with modularity in mind so that users to be able to efficiently customize the training loop for their needs. Below are some examples on how you can apply and test different techniques.
## Train on multiple GPUs / nodes
The trainers in TRL use 🤗 Accelerate to enable distribut... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/logging.mdx | # Logging
As reinforcement learning algorithms are historically challenging to debug, it's important to pay careful attention to logging.
By default, the TRL [`PPOTrainer`] saves a lot of relevant information to `wandb` or `tensorboard`.
Upon initialization, pass one of these two options to the [`PPOConfig`]:
```
con... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/detoxifying_a_lm.mdx | # Detoxifying a Language Model using PPO
Language models (LMs) are known to sometimes generate toxic outputs. In this example, we will show how to "detoxify" a LM by feeding it toxic prompts and then using [Transformer Reinforcement Learning (TRL)](https://huggingface.co/docs/trl/index) and Proximal Policy Optimizatio... | 0 |
hf_public_repos/trl/docs | hf_public_repos/trl/docs/source/multi_adapter_rl.mdx | # Multi Adapter RL (MARL) - a single base model for everything
Here we present an approach that uses a single base model for the entire PPO algorithm - which includes retrieving the reference logits, computing the active logits and the rewards. This feature is experimental as we did not tested the convergence of the a... | 0 |
hf_public_repos/trl | hf_public_repos/trl/scripts/stale.py | # Copyright 2023 The HuggingFace Team, the AllenNLP library authors. 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
#
... | 0 |
hf_public_repos/trl | hf_public_repos/trl/examples/README.md | # Examples
Please check out https://huggingface.co/docs/trl/example_overview for documentation on our examples. | 0 |
hf_public_repos/trl | hf_public_repos/trl/examples/hello_world.py | # 0. imports
import torch
from transformers import GPT2Tokenizer
from trl import AutoModelForCausalLMWithValueHead, PPOConfig, PPOTrainer
# 1. load a pretrained model
model = AutoModelForCausalLMWithValueHead.from_pretrained("gpt2")
model_ref = AutoModelForCausalLMWithValueHead.from_pretrained("gpt2")
tokenizer = GP... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/notebooks/README.md | # Notebooks
This directory contains a collection of Jupyter notebooks that demonstrate how to use the TRL library in different applications.
- [`best_of_n.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/best_of_n.ipynb): This notebook demonstrates how to use the "Best of N" sampling strategy u... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/notebooks/gpt2-sentiment.ipynb | %load_ext autoreload
%autoreload 2%pip install transformers trl wandbimport torch
from tqdm import tqdm
import pandas as pd
tqdm.pandas()
from transformers import pipeline, AutoTokenizer
from datasets import load_dataset
from trl import PPOTrainer, PPOConfig, AutoModelForCausalLMWithValueHead
from trl.core import Le... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/notebooks/best_of_n.ipynb | %pip install transformers trlimport torch
import pandas as pd
from transformers import pipeline, AutoTokenizer
from datasets import load_dataset
from trl import AutoModelForCausalLMWithValueHead
from trl.core import LengthSampler
device = 0 if torch.cuda.is_available() else "cpu"ref_model_name = "lvwerra/gpt2-imdb"
m... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/notebooks/gpt2-sentiment-control.ipynb | %load_ext autoreload
%autoreload 2import random
import torch
import wandb
import time
import os
from tqdm import tqdm
import numpy as np
import pandas as pd
from random import choices
import matplotlib.pyplot as plt
tqdm.pandas()
from datasets import load_dataset
from transformers import AutoTokenizer, pipeline
fro... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/scripts/ppo.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/scripts/dpo.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/scripts/reward_modeling.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/scripts/ddpo.py | # Copyright 2023 metric-space, 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/trl/examples | hf_public_repos/trl/examples/scripts/sft.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/scripts/ppo_multi_adapter.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/research_projects/README.md | # Research projects that use TRL
Welcome to the research projects folder! Here you can find the scripts used for some research projects that used TRL and maintained by the developers and the community (LM de-toxification, Stack-Llama, etc.). Check out the READMEs in the subfolders for more information!
- [De-detoxify... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama | hf_public_repos/trl/examples/research_projects/stack_llama/scripts/merge_peft_adapter.py | from dataclasses import dataclass, field
from typing import Optional
import torch
from peft import PeftConfig, PeftModel
from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer, HfArgumentParser
@dataclass
class ScriptArguments:
"""
The input names representing the Ad... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama | hf_public_repos/trl/examples/research_projects/stack_llama/scripts/README.md | # RLHF pipeline for the creation of StackLLaMa: a Stack exchange llama-7b model.
There were three main steps to the training process:
1. Supervised fine-tuning of the base llama-7b model to create llama-7b-se:
- `torchrun --nnodes 1 --nproc_per_node 8 examples/research_projects/stack_llama/scripts/supervised_finet... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama | hf_public_repos/trl/examples/research_projects/stack_llama/scripts/rl_training.py | # 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama | hf_public_repos/trl/examples/research_projects/stack_llama/scripts/supervised_finetuning.py | import argparse
import os
from accelerate import Accelerator
from datasets import load_dataset
from peft import LoraConfig
from tqdm import tqdm
from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, logging, set_seed
from trl import SFTTrainer
from trl.trainer import ConstantLengthDataset
... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama | hf_public_repos/trl/examples/research_projects/stack_llama/scripts/reward_modeling.py | from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Union
import evaluate
import numpy as np
import torch
import torch.nn as nn
from datasets import load_dataset
from peft import LoraConfig, TaskType, get_peft_model
from transformers import (
AutoModelForSequenceClassification,
... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama_2 | hf_public_repos/trl/examples/research_projects/stack_llama_2/scripts/README.md | # DPO pipeline for the creation of StackLlaMa 2: a Stack exchange llama-v2-7b model
## Prerequisites
Install all the dependencies in the `requirements.txt`:
```
$ pip install -U -r requirements.txt
```
Since we will use `accelerate` for training, make sure to run:
```
$ accelerate config
```
## Training
There wer... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama_2 | hf_public_repos/trl/examples/research_projects/stack_llama_2/scripts/dpo_llama2.py | # 0. imports
import os
from dataclasses import dataclass, field
from typing import Dict, Optional
import torch
from datasets import Dataset, load_dataset
from peft import LoraConfig
from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, TrainingArguments
from trl import DPOTrainer
# Define ... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama_2 | hf_public_repos/trl/examples/research_projects/stack_llama_2/scripts/sft_llama2.py | # Fine-Tune Llama2-7b on SE paired dataset
import os
from dataclasses import dataclass, field
from typing import Optional
import torch
import tyro
from accelerate import Accelerator
from datasets import load_dataset
from peft import AutoPeftModelForCausalLM, LoraConfig
from tqdm import tqdm
from transformers import Au... | 0 |
hf_public_repos/trl/examples/research_projects/stack_llama_2 | hf_public_repos/trl/examples/research_projects/stack_llama_2/scripts/requirements.txt | transformers
trl
peft
accelerate
datasets
bitsandbytes
wandb
| 0 |
hf_public_repos/trl/examples/research_projects | hf_public_repos/trl/examples/research_projects/tools/triviaqa.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples/research_projects | hf_public_repos/trl/examples/research_projects/tools/python_interpreter.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples/research_projects | hf_public_repos/trl/examples/research_projects/tools/calculator.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples/research_projects | hf_public_repos/trl/examples/research_projects/toxicity/README.md | # De-detoxifying language models
To run this code, do the following:
```shell
ACCELERATE_LOG_LEVEL=info accelerate launch --config_file {CONFIG} examples/research_projects/toxicity/scripts/gpt-j-6b-toxicity.py --log_with wandb
```
| 0 |
hf_public_repos/trl/examples/research_projects/toxicity | hf_public_repos/trl/examples/research_projects/toxicity/scripts/evaluate-toxicity.py | import argparse
import csv
import evaluate
import numpy as np
import torch
from datasets import load_dataset
from tqdm import tqdm
from transformers import AutoModelForCausalLM, AutoTokenizer
from trl.import_utils import is_xpu_available
toxicity = evaluate.load("ybelkada/toxicity", "DaNLP/da-electra-hatespeech-det... | 0 |
hf_public_repos/trl/examples/research_projects/toxicity | hf_public_repos/trl/examples/research_projects/toxicity/scripts/gpt-j-6b-toxicity.py | # coding=utf-8
# Copyright 2023 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/LICENSE-2.0
#
# Unless r... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/accelerate_configs/deepspeed_zero1.yaml | compute_environment: LOCAL_MACHINE
debug: false
deepspeed_config:
deepspeed_multinode_launcher: standard
gradient_accumulation_steps: 1
zero3_init_flag: false
zero_stage: 1
distributed_type: DEEPSPEED
downcast_bf16: 'no'
machine_rank: 0
main_training_function: main
mixed_precision: 'bf16'
num_machines: 1
num_pr... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/accelerate_configs/deepspeed_zero2.yaml | compute_environment: LOCAL_MACHINE
debug: false
deepspeed_config:
deepspeed_multinode_launcher: standard
gradient_accumulation_steps: 1
offload_optimizer_device: none
offload_param_device: none
zero3_init_flag: false
zero_stage: 2
distributed_type: DEEPSPEED
downcast_bf16: 'no'
machine_rank: 0
main_training... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/accelerate_configs/deepspeed_zero3.yaml | compute_environment: LOCAL_MACHINE
debug: false
deepspeed_config:
deepspeed_multinode_launcher: standard
gradient_accumulation_steps: 1
offload_optimizer_device: none
offload_param_device: none
zero3_init_flag: true
zero3_save_16bit_model: true
zero_stage: 3
distributed_type: DEEPSPEED
downcast_bf16: 'no'... | 0 |
hf_public_repos/trl/examples | hf_public_repos/trl/examples/accelerate_configs/multi_gpu.yaml | compute_environment: LOCAL_MACHINE
debug: false
distributed_type: MULTI_GPU
downcast_bf16: 'no'
gpu_ids: all
machine_rank: 0
main_training_function: main
mixed_precision: 'bf16'
num_machines: 1
num_processes: 8
rdzv_backend: static
same_network: true
tpu_env: []
tpu_use_cluster: false
tpu_use_sudo: false
use_cpu: false... | 0 |
hf_public_repos | hf_public_repos/datasets/Makefile | .PHONY: quality style test
check_dirs := tests src benchmarks metrics utils
# Check that source code meets quality standards
quality:
ruff check $(check_dirs) setup.py # linter
ruff format --check $(check_dirs) setup.py # formatter
# Format source code automatically
style:
ruff check --fix $(check_dirs) setup.... | 0 |
hf_public_repos | hf_public_repos/datasets/ADD_NEW_DATASET.md | # How to add one new datasets
Add datasets directly to the 🤗 Hugging Face Hub!
You can share your dataset on https://huggingface.co/datasets directly using your account, see the documentation:
* [Create a dataset and upload files on the website](https://huggingface.co/docs/datasets/upload_dataset)
* [Advanced guide... | 0 |
hf_public_repos | hf_public_repos/datasets/dvc.yaml | stages:
benchmark_array_xd:
cmd: python ./benchmarks/benchmark_array_xd.py
deps:
- ./benchmarks/benchmark_array_xd.py
metrics:
- ./benchmarks/results/benchmark_array_xd.json:
cache: false
benchmark_indices_mapping:
cmd: python ./benchmarks/benchmark_indices_mapping.py
deps:
... | 0 |
hf_public_repos | hf_public_repos/datasets/LICENSE |
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
... | 0 |
hf_public_repos | hf_public_repos/datasets/README.md | <p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/datasets-logo-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/d... | 0 |
hf_public_repos | hf_public_repos/datasets/CONTRIBUTING.md | # How to contribute to Datasets?
[](CODE_OF_CONDUCT.md)
Datasets is an open source project, so all contributions and suggestions are welcome.
You can contribute in many different ways: giving ideas, answering questions, reporti... | 0 |
hf_public_repos | hf_public_repos/datasets/CODE_OF_CONDUCT.md | # Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of... | 0 |
hf_public_repos | hf_public_repos/datasets/.pre-commit-config.yaml | repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit # https://github.com/charliermarsh/ruff#usage
rev: 'v0.1.5'
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
| 0 |
hf_public_repos | hf_public_repos/datasets/additional-tests-requirements.txt | unbabel-comet>=1.0.0
git+https://github.com/google-research/bleurt.git
git+https://github.com/ns-moosavi/coval.git
git+https://github.com/hendrycks/math.git
| 0 |
hf_public_repos | hf_public_repos/datasets/.zenodo.json | {
"license": "Apache-2.0",
"creators": [
{
"affiliation": "Hugging Face",
"name": "Quentin Lhoest"
},
{
"orcid": "0000-0003-1727-1045",
"affiliation": "Hugging Face",
"name": "Albert Villanova del Moral"
},
{
... | 0 |
hf_public_repos | hf_public_repos/datasets/setup.py | # Lint as: python3
""" HuggingFace/Datasets is an open library of datasets.
Note:
VERSION needs to be formatted following the MAJOR.MINOR.PATCH convention
(we need to follow this convention to be able to retrieve versioned scripts)
Simple check list for release from AllenNLP repo: https://github.com/allenai/al... | 0 |
hf_public_repos | hf_public_repos/datasets/AUTHORS | # This is the list of HuggingFace Datasets authors for copyright purposes.
#
# This does not necessarily list everyone who has contributed code, since in
# some cases, their employer may be the copyright holder. To see the full list
# of contributors, see the revision history in source control.
Google Inc.
HuggingFac... | 0 |
hf_public_repos | hf_public_repos/datasets/setup.cfg | [metadata]
license_files = LICENSE
[tool:pytest]
# Test fails if a FutureWarning is thrown by `huggingface_hub`
filterwarnings =
error::FutureWarning:huggingface_hub*
markers =
unit: unit test
integration: integration test
| 0 |
hf_public_repos | hf_public_repos/datasets/CITATION.cff | cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "huggingface/datasets"
authors:
- family-names: Lhoest
given-names: Quentin
- family-names: Villanova del Moral
given-names: Albert
orcid: "https://orcid.org/0000-0003-1727-1045"
- family-names: von Platen
given-names: Patri... | 0 |
hf_public_repos | hf_public_repos/datasets/.dvcignore | # Add patterns of files dvc should ignore, which could improve
# the performance. Learn more at
# https://dvc.org/doc/user-guide/dvcignore
| 0 |
hf_public_repos | hf_public_repos/datasets/pyproject.toml | [tool.black]
line-length = 119
target_version = ['py37']
[tool.ruff]
# Ignored rules:
# "E501" -> line length violation
# "F821" -> undefined named in type annotation (e.g. Literal["something"])
# "C901" -> `function_name` is too complex
ignore = ["E501", "F821", "C901"]
select = ["C", "E", "F", "I", "W"]
line-l... | 0 |
hf_public_repos | hf_public_repos/datasets/SECURITY.md | # Security Policy
## Supported Versions
<!--
Use this section to tell people about which versions of your project are
currently being supported with security updates.
| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/keyhash.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/streaming.py | import importlib
import inspect
from functools import wraps
from typing import TYPE_CHECKING, Optional
from .download.download_config import DownloadConfig
from .download.streaming_download_manager import (
xbasename,
xdirname,
xet_parse,
xexists,
xgetsize,
xglob,
xgzip_open,
xisdir,
... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/fingerprint.py | import inspect
import os
import random
import shutil
import tempfile
import weakref
from functools import wraps
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union
import numpy as np
import xxhash
from .naming import INVALID_WINDOWS_CHARACTERS_IN_PATH
from .uti... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/arrow_reader.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/builder.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/load.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/exceptions.py | # SPDX-License-Identifier: Apache-2.0
# Copyright 2023 The HuggingFace Authors.
class DatasetsError(Exception):
"""Base class for exceptions in this library."""
class DefunctDatasetError(DatasetsError):
"""The dataset has been defunct."""
class FileNotFoundDatasetsError(DatasetsError, FileNotFoundError):
... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/combine.py | from typing import List, Optional, TypeVar
from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .info import DatasetInfo
from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interle... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/arrow_writer.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# Unless required by applicable law or agreed to in wr... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/metric.py | # Copyright 2020 The HuggingFace Datasets 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 applicable law or a... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/data_files.py | import os
import re
from functools import partial
from glob import has_magic
from pathlib import Path, PurePath
from typing import Callable, Dict, List, Optional, Set, Tuple, Union
import huggingface_hub
from fsspec import get_fs_token_paths
from fsspec.implementations.http import HTTPFileSystem
from huggingface_hub i... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/dataset_dict.py | import contextlib
import copy
import fnmatch
import json
import math
import posixpath
import re
import warnings
from io import BytesIO
from pathlib import Path
from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
import fsspec
import numpy as np
from huggingface_hub import (
CommitOperationAdd... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/arrow_dataset.py | # Copyright 2020 The HuggingFace 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 applicable law or agreed to... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/splits.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/search.py | import importlib.util
import os
import tempfile
from pathlib import PurePath
from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Union
import fsspec
import numpy as np
from .utils import logging
from .utils import tqdm as hf_tqdm
if TYPE_CHECKING:
from .arrow_dataset import Dataset # noqa: F401... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/naming.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/inspect.py | # Copyright 2020 The HuggingFace Datasets 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 applicable law or ... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/distributed.py | from typing import TypeVar
from .arrow_dataset import Dataset, _split_by_node_map_style_dataset
from .iterable_dataset import IterableDataset, _split_by_node_iterable_dataset
DatasetType = TypeVar("DatasetType", Dataset, IterableDataset)
def split_dataset_by_node(dataset: DatasetType, rank: int, world_size: int) -... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/__init__.py | # flake8: noqa
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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/LI... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/iterable_dataset.py | import copy
import itertools
import sys
import warnings
from collections import Counter
from copy import deepcopy
from dataclasses import dataclass
from functools import partial
from itertools import cycle, islice
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
import numpy as ... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/info.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/table.py | import copy
import os
import warnings
from functools import partial
from itertools import groupby
from typing import TYPE_CHECKING, Callable, Iterator, List, Optional, Tuple, TypeVar, Union
import numpy as np
import pyarrow as pa
import pyarrow.compute as pc
from . import config
from .utils.logging import get_logger
... | 0 |
hf_public_repos/datasets/src | hf_public_repos/datasets/src/datasets/config.py | import importlib
import importlib.metadata
import logging
import os
import platform
from pathlib import Path
from typing import Optional
from packaging import version
logger = logging.getLogger(__name__.split(".", 1)[0]) # to avoid circular import from .utils.logging
# Datasets
S3_DATASETS_BUCKET_PREFIX = "https:/... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/filesystems/compression.py | import os
from typing import Optional
import fsspec
from fsspec.archive import AbstractArchiveFileSystem
from fsspec.utils import DEFAULT_BLOCK_SIZE
class BaseCompressedFileFileSystem(AbstractArchiveFileSystem):
"""Read contents of compressed file as a filesystem with one file inside."""
root_marker = ""
... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/filesystems/s3filesystem.py | import s3fs
from ..utils.deprecation_utils import deprecated
@deprecated("Use s3fs.S3FileSystem instead.")
class S3FileSystem(s3fs.S3FileSystem):
"""
`datasets.filesystems.S3FileSystem` is a subclass of [`s3fs.S3FileSystem`](https://s3fs.readthedocs.io/en/latest/api.html).
Users can use this class to ac... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/filesystems/__init__.py | import importlib
import shutil
import threading
import warnings
from typing import List
import fsspec
import fsspec.asyn
from fsspec.implementations.local import LocalFileSystem
from ..utils.deprecation_utils import deprecated
from . import compression
_has_s3fs = importlib.util.find_spec("s3fs") is not None
if _h... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/beam_utils.py | import os
from apache_beam.io.filesystems import FileSystems
from apache_beam.pipeline import Pipeline
from .logging import get_logger
CHUNK_SIZE = 2 << 20 # 2mb
logger = get_logger(__name__)
class BeamPipeline(Pipeline):
"""Wrapper over `apache_beam.pipeline.Pipeline` for convenience"""
def is_local(se... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/experimental.py | """Contains utilities to flag a feature as "experimental" in datasets."""
import warnings
from functools import wraps
from typing import Callable
def experimental(fn: Callable) -> Callable:
"""Decorator to flag a feature as experimental.
An experimental feature trigger a warning when used as it might be subj... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/tf_utils.py | # Copyright 2022 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/py_utils.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# U... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/tqdm.py | """Utility helpers to handle progress bars in `datasets`.
Example:
1. Use `datasets.utils.tqdm` as you would use `tqdm.tqdm` or `tqdm.auto.tqdm`.
2. To disable progress bars, either use `disable_progress_bars()` helper or set the
environment variable `HF_DATASETS_DISABLE_PROGRESS_BARS` to 1.
3. To r... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/_dill.py | # Copyright 2023 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/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/stratify.py | import numpy as np
def approximate_mode(class_counts, n_draws, rng):
"""Computes approximate mode of multivariate hypergeometric.
This is an approximation to the mode of the multivariate
hypergeometric given by class_counts and n_draws.
It shouldn't be off by more than one.
It is the mostly likely... | 0 |
hf_public_repos/datasets/src/datasets | hf_public_repos/datasets/src/datasets/utils/hub.py | from typing import Optional
from urllib.parse import quote
import huggingface_hub as hfh
from packaging import version
def hf_hub_url(repo_id: str, path: str, revision: Optional[str] = None) -> str:
if version.parse(hfh.__version__).release < version.parse("0.11.0").release:
# old versions of hfh don't u... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.