repo_id
stringlengths
15
89
file_path
stringlengths
27
180
content
stringlengths
1
2.23M
__index_level_0__
int64
0
0
hf_public_repos/diffusers/src/diffusers/models
hf_public_repos/diffusers/src/diffusers/models/autoencoders/autoencoder_tiny.py
# Copyright 2023 Ollin Boer Bohan 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://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
0
hf_public_repos/diffusers/src/diffusers/models
hf_public_repos/diffusers/src/diffusers/models/autoencoders/__init__.py
from .autoencoder_asym_kl import AsymmetricAutoencoderKL from .autoencoder_kl import AutoencoderKL from .autoencoder_kl_temporal_decoder import AutoencoderKLTemporalDecoder from .autoencoder_tiny import AutoencoderTiny from .consistency_decoder_vae import ConsistencyDecoderVAE
0
hf_public_repos/diffusers/src/diffusers/models
hf_public_repos/diffusers/src/diffusers/models/autoencoders/autoencoder_asym_kl.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/diffusers/src/diffusers/models
hf_public_repos/diffusers/src/diffusers/models/autoencoders/vae.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/diffusers/src/diffusers/models
hf_public_repos/diffusers/src/diffusers/models/autoencoders/consistency_decoder_vae.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_torch_and_torchsde_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class DPMSolverSDEScheduler(metaclass=DummyObject): _backends = ["torch", "torchsde"] def __init__(self, *args, **kwargs): requires_backends(self, ["torch", "torchsde"]) ...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/accelerate_utils.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/pil_utils.py
from typing import List import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"): PIL_INTERPOLATION = { "linear": PIL.Image.Resampling.BILINEAR, "bilinear": PIL.Image.Resampling...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/doc_utils.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_torch_and_scipy_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class LMSDiscreteScheduler(metaclass=DummyObject): _backends = ["torch", "scipy"] def __init__(self, *args, **kwargs): requires_backends(self, ["torch", "scipy"]) @class...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_torch_and_transformers_and_k_diffusion_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class StableDiffusionKDiffusionPipeline(metaclass=DummyObject): _backends = ["torch", "transformers", "k_diffusion"] def __init__(self, *args, **kwargs): requires_backends(se...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/outputs.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/import_utils.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/model_card_template.md
--- {{ card_data }} --- <!-- This model card has been generated automatically according to the information the training script had access to. You should probably proofread and complete it, then remove this comment. --> # {{ model_name | default("Diffusion Model") }} ## Model description This diffusion model is trai...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/deprecation_utils.py
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def deprecate(*args, take_from: Optional[Union[Dict, Any]] = None, standard_warn=True, stacklevel=2): from .. import __version__ deprecated_kwargs = take_from values = () if not isinstance(args...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_torch_and_transformers_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class AltDiffusionImg2ImgPipeline(metaclass=DummyObject): _backends = ["torch", "transformers"] def __init__(self, *args, **kwargs): requires_backends(self, ["torch", "transf...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dynamic_modules_utils.py
# coding=utf-8 # Copyright 2023 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
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/versions.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_note_seq_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class MidiProcessor(metaclass=DummyObject): _backends = ["note_seq"] def __init__(self, *args, **kwargs): requires_backends(self, ["note_seq"]) @classmethod def from...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_torch_and_transformers_and_onnx_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class OnnxStableDiffusionImg2ImgPipeline(metaclass=DummyObject): _backends = ["torch", "transformers", "onnx"] def __init__(self, *args, **kwargs): requires_backends(self, ["...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/testing_utils.py
import functools import importlib import inspect import io import logging import multiprocessing import os import random import re import struct import sys import tempfile import time import unittest import urllib.parse from contextlib import contextmanager from distutils.util import strtobool from io import BytesIO, S...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/hub_utils.py
# coding=utf-8 # Copyright 2023 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
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_torch_and_librosa_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class AudioDiffusionPipeline(metaclass=DummyObject): _backends = ["torch", "librosa"] def __init__(self, *args, **kwargs): requires_backends(self, ["torch", "librosa"]) ...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/__init__.py
# 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 required by appl...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/loading_utils.py
import os from typing import Callable, Union import PIL.Image import PIL.ImageOps import requests def load_image( image: Union[str, PIL.Image.Image], convert_method: Callable[[PIL.Image.Image], PIL.Image.Image] = None ) -> PIL.Image.Image: """ Loads `image` to a PIL Image. Args: image (`str`...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/logging.py
# coding=utf-8 # Copyright 2023 Optuna, Hugging Face # # 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
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/state_dict_utils.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_transformers_and_torch_and_note_seq_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class SpectrogramDiffusionPipeline(metaclass=DummyObject): _backends = ["transformers", "torch", "note_seq"] def __init__(self, *args, **kwargs): requires_backends(self, ["tr...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/torch_utils.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_flax_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class FlaxControlNetModel(metaclass=DummyObject): _backends = ["flax"] def __init__(self, *args, **kwargs): requires_backends(self, ["flax"]) @classmethod def from_c...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_flax_and_transformers_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class FlaxStableDiffusionControlNetPipeline(metaclass=DummyObject): _backends = ["flax", "transformers"] def __init__(self, *args, **kwargs): requires_backends(self, ["flax",...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/export_utils.py
import io import random import struct import tempfile from contextlib import contextmanager from typing import List, Union import numpy as np import PIL.Image import PIL.ImageOps from .import_utils import ( BACKENDS_MAPPING, is_opencv_available, ) from .logging import get_logger global_rng = random.Random()...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_onnx_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class OnnxRuntimeModel(metaclass=DummyObject): _backends = ["onnx"] def __init__(self, *args, **kwargs): requires_backends(self, ["onnx"]) @classmethod def from_conf...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/constants.py
# 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 required by appl...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/peft_utils.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/utils/dummy_pt_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class AsymmetricAutoencoderKL(metaclass=DummyObject): _backends = ["torch"] def __init__(self, *args, **kwargs): requires_backends(self, ["torch"]) @classmethod def ...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/commands/__init__.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/commands/env.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/commands/fp16_safetensors.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/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/commands/diffusers_cli.py
#!/usr/bin/env python # 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...
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/experimental/README.md
# 🧨 Diffusers Experimental We are adding experimental code to support novel applications and usages of the Diffusers library. Currently, the following experiments are supported: * Reinforcement learning via an implementation of the [Diffuser](https://arxiv.org/abs/2205.09991) model.
0
hf_public_repos/diffusers/src/diffusers
hf_public_repos/diffusers/src/diffusers/experimental/__init__.py
from .rl import ValueGuidedRLPipeline
0
hf_public_repos/diffusers/src/diffusers/experimental
hf_public_repos/diffusers/src/diffusers/experimental/rl/value_guided_sampling.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/diffusers/src/diffusers/experimental
hf_public_repos/diffusers/src/diffusers/experimental/rl/__init__.py
from .value_guided_sampling import ValueGuidedRLPipeline
0
hf_public_repos
hf_public_repos/trl/.pre-commit-config.yaml
repos: - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort args: - --profile=black - --skip-glob=wandb/**/* - --thirdparty=wandb - repo: https://github.com/myint/autoflake rev: v1.4 hooks: - id: autoflake args: - -...
0
hf_public_repos
hf_public_repos/trl/setup.cfg
[metadata] license_file = LICENSE [isort] ensure_newline_before_comments = True force_grid_wrap = 0 include_trailing_comma = True line_length = 119 lines_after_imports = 2 multi_line_output = 3 use_parentheses = True
0
hf_public_repos
hf_public_repos/trl/README.md
<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 > Full stack transformer language models with reinforcement learning. <p align="center"> <a href="https://githu...
0
hf_public_repos
hf_public_repos/trl/pyproject.toml
[tool.black] line-length = 119 target-version = ['py38'] [tool.ruff] ignore = ["E501", "E741", "W605"] select = ["E", "F", "I", "W"] line-length = 119 # Ignore import violations in all `__init__.py` files. [tool.ruff.per-file-ignores] "__init__.py" = ["E402", "F401", "F403", "F811"] [tool.ruff.isort] lines-after-imp...
0
hf_public_repos
hf_public_repos/trl/CONTRIBUTING.md
# How to contribute ## How to get started Before you start contributing make sure you installed all the dev tools: ```bash pip install -e ".[dev]" ``` ## Did you find a bug? * Ensure the bug was not already reported by searching on GitHub under Issues. * If you're unable to find an open issue addressing the proble...
0
hf_public_repos
hf_public_repos/trl/requirements.txt
datasets>=1.17.0 torch>=1.4.0 tqdm transformers accelerate peft>=0.3.0 tyro>=0.5.7
0
hf_public_repos
hf_public_repos/trl/setup.py
""" trl is an open library for RL with transformer models. 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/allennlp/blob/maste...
0
hf_public_repos
hf_public_repos/trl/CITATION.cff
cff-version: 1.2.0 title: 'TRL: Transformer Reinforcement Learning' message: >- If you use this software, please cite it using the metadata from this file. type: software authors: - given-names: Leandro family-names: von Werra - given-names: Younes family-names: Belkada - given-names: Lewis family...
0
hf_public_repos
hf_public_repos/trl/MANIFEST.in
include settings.ini include LICENSE include CONTRIBUTING.md include README.md recursive-exclude * __pycache__
0
hf_public_repos
hf_public_repos/trl/Makefile
.PHONY: test precommit benchmark_core benchmark_aux common_tests slow_tests test_examples tests_gpu check_dirs := examples tests trl ACCELERATE_CONFIG_PATH = `pwd`/examples/accelerate_configs COMMAND_FILES_PATH = `pwd`/commands test: python -m pytest -n auto --dist=loadfile -s -v ./tests/ precommit: pre-commit ru...
0
hf_public_repos
hf_public_repos/trl/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/trl
hf_public_repos/trl/scripts/log_example_reports.py
# Copyright 2024 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/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/scripts/log_reports.py
# Copyright 2024 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/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
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/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/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/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/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/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/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/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_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/sft_llama2.py
# Fine-Tune Llama2-7b on SE paired dataset import os from dataclasses import dataclass, field from typing import Optional import torch from accelerate import Accelerator from datasets import load_dataset from peft import AutoPeftModelForCausalLM, LoraConfig from tqdm import tqdm from transformers import AutoModelForCa...
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/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
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_npu_available, is_xpu_available toxicity = evaluate.load("ybelkada/toxicity", "DaNLP/da-elec...
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/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/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/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/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
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/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/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/accelerate_configs/single_gpu.yaml
compute_environment: LOCAL_MACHINE debug: false distributed_type: "NO" 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/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/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/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/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
hf_public_repos/trl/benchmark/benchmark.py
import argparse import math import os import shlex import subprocess import uuid from distutils.util import strtobool import requests def parse_args(): # fmt: off parser = argparse.ArgumentParser() parser.add_argument("--command", type=str, default="", help="the command to run") parser.add_ar...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/benchmark_level1_plot.sh
# pip install openrlbenchmark==0.2.1a5 # see https://github.com/openrlbenchmark/openrlbenchmark#get-started for documentation echo "we deal with $TAGS_STRING" python -m openrlbenchmark.rlops_multi_metrics \ --filters '?we=huggingface&wpn=trl&xaxis=_step&ceik=trl_ppo_trainer_config.value.reward_model&cen=trl_ppo_tr...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/post_github_comment.py
import json import os from ghapi.all import GhApi FOLDER_STRING = os.environ.get("FOLDER_STRING", "") folder = f"benchmark/trl/{FOLDER_STRING}" host_url = f"https://huggingface.co/datasets/trl-internal-testing/example-images/resolve/main/images/benchmark/{FOLDER_STRING}" # Create a GitHub API instance github_contex...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/benchmark_level3.sh
## w/ and w/o gradient accumulation python benchmark/benchmark.py \ --command "python examples/scripts/ppo.py --ppo_config.exp_name ppo_step_grad_accu --ppo_config.mini_batch_size 1 --ppo_config.gradient_accumulation_steps 128 --ppo_config.log_with wandb" \ --num-seeds 3 \ --start-seed 1 \ --workers 10 ...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/benchmark_and_report.sh
#### Step 1: create a work directory: # this is necessary because another github action job will remove # the entire directory, which slurm depends on. # https://stackoverflow.com/questions/4632028/how-to-create-a-temporary-directory MY_SLURM_TMP_DIR=/fsx/costa/slurm_tmpdir mkdir -p $MY_SLURM_TMP_DIR WORK_DIR=`mktemp -...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/upload_benchmark.py
from dataclasses import dataclass import tyro from huggingface_hub import HfApi @dataclass class Args: folder_path: str = "benchmark/trl" path_in_repo: str = "images/benchmark" repo_id: str = "trl-internal-testing/example-images" repo_type: str = "dataset" args = tyro.cli(Args) api = HfApi() api.u...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/benchmark_level1.sh
# hello world experiment python benchmark/benchmark.py \ --command "python examples/scripts/ppo.py --ppo_config.log_with wandb" \ --num-seeds 3 \ --start-seed 1 \ --workers 10 \ --slurm-nodes 1 \ --slurm-gpus-per-task 1 \ --slurm-ntasks 1 \ --slurm-total-cpus 12 \ --slurm-template-pa...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/benchmark_level2_plot.sh
# pip install openrlbenchmark==0.2.1a5 # see https://github.com/openrlbenchmark/openrlbenchmark#get-started for documentation echo "we deal with $TAGS_STRING" python -m openrlbenchmark.rlops_multi_metrics \ --filters '?we=huggingface&wpn=trl&xaxis=_step&ceik=trl_ppo_trainer_config.value.reward_model&cen=trl_ppo_tr...
0
hf_public_repos/trl
hf_public_repos/trl/benchmark/benchmark_level2.sh
# compound experiments: gpt2xl + grad_accu python benchmark/benchmark.py \ --command "python examples/scripts/ppo.py --ppo_config.exp_name ppo_gpt2xl_grad_accu --ppo_config.model_name gpt2-xl --ppo_config.mini_batch_size 16 --ppo_config.gradient_accumulation_steps 8 --ppo_config.log_with wandb" \ --num-seeds 3 ...
0