text
stringlengths
7
1.24M
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
519
{ "model_type": "roberta" }
transformers/tests/fixtures/dummy-config.json/0
{ "file_path": "transformers/tests/fixtures/dummy-config.json", "repo_id": "transformers", "token_count": 15 }
466
""" Framework agnostic tests for generate()-related methods. """ import numpy as np from transformers import AutoTokenizer from transformers.testing_utils import slow, torch_device class GenerationIntegrationTestsMixin: # To be populated by the child classes framework_dependent_parameters = { "AutoM...
transformers/tests/generation/test_framework_agnostic.py/0
{ "file_path": "transformers/tests/generation/test_framework_agnostic.py", "repo_id": "transformers", "token_count": 14177 }
467
# 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...
transformers/tests/models/autoformer/test_modeling_autoformer.py/0
{ "file_path": "transformers/tests/models/autoformer/test_modeling_autoformer.py", "repo_id": "transformers", "token_count": 8882 }
468
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
transformers/tests/models/beit/test_modeling_flax_beit.py/0
{ "file_path": "transformers/tests/models/beit/test_modeling_flax_beit.py", "repo_id": "transformers", "token_count": 4819 }
469
# 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...
transformers/tests/models/big_bird/test_modeling_flax_big_bird.py/0
{ "file_path": "transformers/tests/models/big_bird/test_modeling_flax_big_bird.py", "repo_id": "transformers", "token_count": 3793 }
470
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
transformers/tests/models/blenderbot_small/test_modeling_flax_blenderbot_small.py/0
{ "file_path": "transformers/tests/models/blenderbot_small/test_modeling_flax_blenderbot_small.py", "repo_id": "transformers", "token_count": 7912 }
471
# 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-2.0 # # Unless requir...
transformers/tests/models/bloom/test_tokenization_bloom.py/0
{ "file_path": "transformers/tests/models/bloom/test_tokenization_bloom.py", "repo_id": "transformers", "token_count": 3278 }
472
# coding=utf-8 # Copyright 2024 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
transformers/tests/models/chameleon/test_image_processing_chameleon.py/0
{ "file_path": "transformers/tests/models/chameleon/test_image_processing_chameleon.py", "repo_id": "transformers", "token_count": 3583 }
473
# 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...
transformers/tests/models/clip/test_tokenization_clip.py/0
{ "file_path": "transformers/tests/models/clip/test_tokenization_clip.py", "repo_id": "transformers", "token_count": 4026 }
474
# 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-2.0 # # Unless requir...
transformers/tests/models/cohere/test_tokenization_cohere.py/0
{ "file_path": "transformers/tests/models/cohere/test_tokenization_cohere.py", "repo_id": "transformers", "token_count": 6207 }
475
# 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...
transformers/tests/models/data2vec/test_modeling_data2vec_vision.py/0
{ "file_path": "transformers/tests/models/data2vec/test_modeling_data2vec_vision.py", "repo_id": "transformers", "token_count": 6449 }
476
# 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...
transformers/tests/models/deformable_detr/test_modeling_deformable_detr.py/0
{ "file_path": "transformers/tests/models/deformable_detr/test_modeling_deformable_detr.py", "repo_id": "transformers", "token_count": 15647 }
477
# 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...
transformers/tests/models/dpt/test_modeling_dpt.py/0
{ "file_path": "transformers/tests/models/dpt/test_modeling_dpt.py", "repo_id": "transformers", "token_count": 6571 }
478
# 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 applicabl...
transformers/tests/models/git/test_processor_git.py/0
{ "file_path": "transformers/tests/models/git/test_processor_git.py", "repo_id": "transformers", "token_count": 2169 }
479
# 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...
transformers/tests/models/gpt_neox/test_modeling_gpt_neox.py/0
{ "file_path": "transformers/tests/models/gpt_neox/test_modeling_gpt_neox.py", "repo_id": "transformers", "token_count": 10604 }
480
# 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 applicabl...
transformers/tests/models/idefics/test_processor_idefics.py/0
{ "file_path": "transformers/tests/models/idefics/test_processor_idefics.py", "repo_id": "transformers", "token_count": 3514 }
481
# coding=utf-8 # Copyright 2022 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
transformers/tests/models/mask2former/test_image_processing_mask2former.py/0
{ "file_path": "transformers/tests/models/mask2former/test_image_processing_mask2former.py", "repo_id": "transformers", "token_count": 10398 }
482
# 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 requir...
transformers/tests/models/megatron_gpt2/test_modeling_megatron_gpt2.py/0
{ "file_path": "transformers/tests/models/megatron_gpt2/test_modeling_megatron_gpt2.py", "repo_id": "transformers", "token_count": 1286 }
483
# coding=utf-8 # Copyright 2022 Leon Derczynski. 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...
transformers/tests/models/mobilebert/test_tokenization_mobilebert.py/0
{ "file_path": "transformers/tests/models/mobilebert/test_tokenization_mobilebert.py", "repo_id": "transformers", "token_count": 7679 }
484
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. team, Microsoft Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless...
transformers/tests/models/mpnet/test_tokenization_mpnet.py/0
{ "file_path": "transformers/tests/models/mpnet/test_tokenization_mpnet.py", "repo_id": "transformers", "token_count": 1217 }
485
# 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 ...
transformers/tests/models/plbart/test_modeling_plbart.py/0
{ "file_path": "transformers/tests/models/plbart/test_modeling_plbart.py", "repo_id": "transformers", "token_count": 12121 }
486
# 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...
transformers/tests/models/rag/test_retrieval_rag.py/0
{ "file_path": "transformers/tests/models/rag/test_retrieval_rag.py", "repo_id": "transformers", "token_count": 6761 }
487
# 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...
transformers/tests/models/resnet/test_modeling_flax_resnet.py/0
{ "file_path": "transformers/tests/models/resnet/test_modeling_flax_resnet.py", "repo_id": "transformers", "token_count": 3543 }
488
# 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...
transformers/tests/models/seamless_m4t/test_modeling_seamless_m4t.py/0
{ "file_path": "transformers/tests/models/seamless_m4t/test_modeling_seamless_m4t.py", "repo_id": "transformers", "token_count": 22134 }
489
# 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 applicabl...
transformers/tests/models/speecht5/test_processor_speecht5.py/0
{ "file_path": "transformers/tests/models/speecht5/test_processor_speecht5.py", "repo_id": "transformers", "token_count": 2860 }
490
# coding=utf-8 # Copyright 2024 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...
transformers/tests/models/swiftformer/test_modeling_tf_swiftformer.py/0
{ "file_path": "transformers/tests/models/swiftformer/test_modeling_tf_swiftformer.py", "repo_id": "transformers", "token_count": 4215 }
491
# coding=utf-8 # Copyright 2023 The Intel Team Authors, 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/...
transformers/tests/models/tvp/test_modeling_tvp.py/0
{ "file_path": "transformers/tests/models/tvp/test_modeling_tvp.py", "repo_id": "transformers", "token_count": 5909 }
492
# 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...
transformers/tests/models/vit_msn/test_modeling_vit_msn.py/0
{ "file_path": "transformers/tests/models/vit_msn/test_modeling_vit_msn.py", "repo_id": "transformers", "token_count": 3553 }
493
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
transformers/tests/models/wav2vec2/test_modeling_wav2vec2.py/0
{ "file_path": "transformers/tests/models/wav2vec2/test_modeling_wav2vec2.py", "repo_id": "transformers", "token_count": 39421 }
494
# 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...
transformers/tests/models/whisper/test_modeling_flax_whisper.py/0
{ "file_path": "transformers/tests/models/whisper/test_modeling_flax_whisper.py", "repo_id": "transformers", "token_count": 18408 }
495
# 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...
transformers/tests/pipelines/test_pipelines_fill_mask.py/0
{ "file_path": "transformers/tests/pipelines/test_pipelines_fill_mask.py", "repo_id": "transformers", "token_count": 9758 }
496
# 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...
transformers/tests/pipelines/test_pipelines_translation.py/0
{ "file_path": "transformers/tests/pipelines/test_pipelines_translation.py", "repo_id": "transformers", "token_count": 3151 }
497
# coding=utf-8 # 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 requir...
transformers/tests/quantization/eetq_integration/test_eetq.py/0
{ "file_path": "transformers/tests/quantization/eetq_integration/test_eetq.py", "repo_id": "transformers", "token_count": 2613 }
498
# 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 applicabl...
transformers/tests/repo_utils/test_tests_fetcher.py/0
{ "file_path": "transformers/tests/repo_utils/test_tests_fetcher.py", "repo_id": "transformers", "token_count": 17320 }
499
# coding=utf-8 # Copyright 2023 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
transformers/tests/test_image_processing_common.py/0
{ "file_path": "transformers/tests/test_image_processing_common.py", "repo_id": "transformers", "token_count": 10432 }
500
# 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...
transformers/tests/trainer/test_trainer_distributed.py/0
{ "file_path": "transformers/tests/trainer/test_trainer_distributed.py", "repo_id": "transformers", "token_count": 4117 }
501
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
transformers/tests/utils/test_doc_samples.py/0
{ "file_path": "transformers/tests/utils/test_doc_samples.py", "repo_id": "transformers", "token_count": 1749 }
502
# coding=utf-8 # Copyright 2019 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
transformers/tests/utils/test_modeling_utils.py/0
{ "file_path": "transformers/tests/utils/test_modeling_utils.py", "repo_id": "transformers", "token_count": 53785 }
503
# 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...
transformers/utils/check_model_tester.py/0
{ "file_path": "transformers/utils/check_model_tester.py", "repo_id": "transformers", "token_count": 1240 }
504
# 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...
transformers/utils/get_test_info.py/0
{ "file_path": "transformers/utils/get_test_info.py", "repo_id": "transformers", "token_count": 2737 }
505
# 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...
transformers/utils/split_model_tests.py/0
{ "file_path": "transformers/utils/split_model_tests.py", "repo_id": "transformers", "token_count": 759 }
506
export WANDB_ENTITY=huggingface export WANDB_PROJECT=trl bash $BENCHMARK_SCRIPT > output.txt # Extract Job IDs into an array job_ids=($(grep "Job ID:" output.txt | awk '{print $3}')) # Extract WANDB_TAGS into an array WANDB_TAGS=($(grep "WANDB_TAGS:" output.txt | awk '{print $2}')) WANDB_TAGS=($(echo $WANDB_TAGS | tr...
trl/benchmark/benchmark_and_report.sh/0
{ "file_path": "trl/benchmark/benchmark_and_report.sh", "repo_id": "trl", "token_count": 387 }
507
- sections: - local: index title: TRL - local: quickstart title: Quickstart - local: installation title: Installation - local: clis title: Get started with Command Line Interfaces (CLIs) - local: how_to_train title: PPO Training FAQ - local: use_model title: Use Trained Models - lo...
trl/docs/source/_toctree.yml/0
{ "file_path": "trl/docs/source/_toctree.yml", "repo_id": "trl", "token_count": 692 }
508
# Judges TRL provides judges to easily compare two completions. Make sure to have installed the required dependencies by running: ```bash pip install trl[llm_judge] ``` ## Using the provided judges TRL provides several judges out of the box. For example, you can use the `HfPairwiseJudge` to compare two completions...
trl/docs/source/judges.mdx/0
{ "file_path": "trl/docs/source/judges.mdx", "repo_id": "trl", "token_count": 695 }
509
# Text Environments Text environments provide a learning ground for language agents. It allows a language model to use tools to accomplish a task such as using a Python interpreter to answer math questions or using a search index for trivia questions. Having access to tools allows language models to solve tasks that w...
trl/docs/source/text_environments.md/0
{ "file_path": "trl/docs/source/text_environments.md", "repo_id": "trl", "token_count": 2826 }
510
# 0. imports import torch from transformers import GPT2Tokenizer from trl import AutoModelForCausalLMWithValueHead, PPOConfig, PPOTrainer # 1. load a pretrained model model = AutoModelForCausalLMWithValueHead.from_pretrained("gpt2") ref_model = AutoModelForCausalLMWithValueHead.from_pretrained("gpt2") tokenizer = GP...
trl/examples/hello_world.py/0
{ "file_path": "trl/examples/hello_world.py", "repo_id": "trl", "token_count": 501 }
511
# 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...
trl/examples/research_projects/tools/python_interpreter.py/0
{ "file_path": "trl/examples/research_projects/tools/python_interpreter.py", "repo_id": "trl", "token_count": 2604 }
512
# Copyright 2024 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...
trl/examples/scripts/orpo.py/0
{ "file_path": "trl/examples/scripts/orpo.py", "repo_id": "trl", "token_count": 1684 }
513
""" 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...
trl/setup.py/0
{ "file_path": "trl/setup.py", "repo_id": "trl", "token_count": 1956 }
514
import subprocess def test_hello_world(): subprocess.run( "python examples/hello_world.py", shell=True, check=True, )
trl/tests/test_e2e.py/0
{ "file_path": "trl/tests/test_e2e.py", "repo_id": "trl", "token_count": 69 }
515
import tempfile import unittest import datasets from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer from trl import ( BCOConfig, BCOTrainer, CPOConfig, CPOTrainer, DPOConfig, DPOTrainer, KTOConfig, KTOTrainer, OnlineDPOConfig, Online...
trl/tests/test_trainers_args.py/0
{ "file_path": "trl/tests/test_trainers_args.py", "repo_id": "trl", "token_count": 7924 }
516
# flake8: noqa # 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 requi...
trl/trl/models/__init__.py/0
{ "file_path": "trl/trl/models/__init__.py", "repo_id": "trl", "token_count": 805 }
517
import os import sys import warnings from dataclasses import dataclass, field from typing import Literal, Optional from ..core import flatten_dict from ..import_utils import is_bitsandbytes_available, is_torchvision_available @dataclass class DDPOConfig: """ Configuration class for DDPOTrainer """ #...
trl/trl/trainer/ddpo_config.py/0
{ "file_path": "trl/trl/trainer/ddpo_config.py", "repo_id": "trl", "token_count": 1776 }
518
import gc import math import os import time from collections import defaultdict from functools import wraps from typing import Dict, List, Optional, Tuple, Union import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F from accelerate import Accelerator from accelerate....
trl/trl/trainer/ppov2_trainer.py/0
{ "file_path": "trl/trl/trainer/ppov2_trainer.py", "repo_id": "trl", "token_count": 16088 }
519
.PHONY: quality style test docs utils check_dirs := . # Check that source code meets quality standards extra_quality_checks: python utils/check_copies.py python utils/check_dummies.py python utils/check_repo.py doc-builder style src/accelerate docs/source --max_len 119 # this target runs checks on all files qua...
accelerate/Makefile/0
{ "file_path": "accelerate/Makefile", "repo_id": "accelerate", "token_count": 1111 }
0
<!--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 agreed...
accelerate/docs/source/concept_guides/internal_mechanism.md/0
{ "file_path": "accelerate/docs/source/concept_guides/internal_mechanism.md", "repo_id": "accelerate", "token_count": 1194 }
1
<!--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 agreed...
accelerate/docs/source/usage_guides/ipex.md/0
{ "file_path": "accelerate/docs/source/usage_guides/ipex.md", "repo_id": "accelerate", "token_count": 2636 }
2
# This config template simply setups up the TransformersEngine config (and a config for a single GPU), # this can interop with the other configs in this folder distributed_type: "NO" mixed_precision: "fp8" # Then we specify the fp8 configuration: fp8_config: backend: TE # Can be TE | MS-AMP # The following are TE s...
accelerate/examples/config_yaml_templates/fp8.yaml/0
{ "file_path": "accelerate/examples/config_yaml_templates/fp8.yaml", "repo_id": "accelerate", "token_count": 239 }
3
# Copyright 2024 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...
accelerate/examples/inference/pippy/bert.py/0
{ "file_path": "accelerate/examples/inference/pippy/bert.py", "repo_id": "accelerate", "token_count": 871 }
4
# 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 applicabl...
accelerate/manim_animations/big_model_inference/stage_4.py/0
{ "file_path": "accelerate/manim_animations/big_model_inference/stage_4.py", "repo_id": "accelerate", "token_count": 2919 }
5
# Copyright 2022 The HuggingFace Team and Brian Chao. 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...
accelerate/src/accelerate/commands/menu/input.py/0
{ "file_path": "accelerate/src/accelerate/commands/menu/input.py", "repo_id": "accelerate", "token_count": 947 }
6
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/state.py/0
{ "file_path": "accelerate/src/accelerate/state.py", "repo_id": "accelerate", "token_count": 22587 }
7
#!/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 # # Unles...
accelerate/src/accelerate/test_utils/scripts/test_ops.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/test_ops.py", "repo_id": "accelerate", "token_count": 2359 }
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-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/utils/memory.py/0
{ "file_path": "accelerate/src/accelerate/utils/memory.py", "repo_id": "accelerate", "token_count": 2041 }
9
# 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 applicabl...
accelerate/tests/test_big_modeling.py/0
{ "file_path": "accelerate/tests/test_big_modeling.py", "repo_id": "accelerate", "token_count": 18688 }
10
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_kwargs_handlers.py/0
{ "file_path": "accelerate/tests/test_kwargs_handlers.py", "repo_id": "accelerate", "token_count": 3281 }
11
# 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 applicabl...
accelerate/tests/test_tracking.py/0
{ "file_path": "accelerate/tests/test_tracking.py", "repo_id": "accelerate", "token_count": 10128 }
12
# Constitutional AI This repo includes the recipe for training the following models: * https://huggingface.co/HuggingFaceH4/mistral-7b-anthropic * https://huggingface.co/HuggingFaceH4/mistral-7b-grok ## Full training examples You will require 8 GPUs (80GB of VRAM) to train the full model. ```shell # Step 1 - SFT ...
alignment-handbook/recipes/constitutional-ai/README.md/0
{ "file_path": "alignment-handbook/recipes/constitutional-ai/README.md", "repo_id": "alignment-handbook", "token_count": 327 }
13
# Model arguments model_name_or_path: HuggingFaceH4/starchat2-15b-sft-v0.1 torch_dtype: bfloat16 # Data training arguments # For definitions, see: src/h4/training/config.py dataset_mixer: HuggingFaceH4/ultrafeedback_binarized: 1.0 HuggingFaceH4/orca_dpo_pairs: 1.0 dataset_splits: - train_prefs - test_prefs preproc...
alignment-handbook/recipes/starchat2-15b/dpo/config_v0.1.yaml/0
{ "file_path": "alignment-handbook/recipes/starchat2-15b/dpo/config_v0.1.yaml", "repo_id": "alignment-handbook", "token_count": 398 }
14
#!/usr/bin/env python # 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/LI...
alignment-handbook/scripts/run_sft.py/0
{ "file_path": "alignment-handbook/scripts/run_sft.py", "repo_id": "alignment-handbook", "token_count": 3196 }
15
[build] rustflags = ["-C", "target-cpu=native"] [target.wasm32-unknown-unknown] rustflags = ["-C", "target-feature=+simd128"] [target.x86_64-apple-darwin] rustflags = ["-C", "target-feature=-avx,-avx2"]
candle/.cargo/config.toml/0
{ "file_path": "candle/.cargo/config.toml", "repo_id": "candle", "token_count": 84 }
16
# Introduction {{#include ../../README.md:features}} This book will introduce step by step how to use `candle`.
candle/candle-book/src/README.md/0
{ "file_path": "candle/candle-book/src/README.md", "repo_id": "candle", "token_count": 34 }
17
# Porting a custom kernel
candle/candle-book/src/inference/cuda/porting.md/0
{ "file_path": "candle/candle-book/src/inference/cuda/porting.md", "repo_id": "candle", "token_count": 7 }
18
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle_core::{DType, Device, Tensor}; use criterion::{black_box, criterion_group, Criterion, Throughput}; use std::time::Instant; fn run( x: &Tensor, k: &Tensor, padding: usize, output_padding: usize, stride: usize, dilation: usize, ...
candle/candle-core/benches/benchmarks/conv_transpose2d.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/conv_transpose2d.rs", "repo_id": "candle", "token_count": 826 }
19
use super::{Cpu, CpuF16}; #[cfg(target_arch = "x86")] use core::arch::x86::*; #[cfg(target_arch = "x86_64")] use core::arch::x86_64::*; use half::f16; pub struct CurrentCpu {} const STEP: usize = 32; const EPR: usize = 8; const ARR: usize = STEP / EPR; impl Cpu<ARR> for CurrentCpu { type Unit = __m256; type...
candle/candle-core/src/cpu/avx.rs/0
{ "file_path": "candle/candle-core/src/cpu/avx.rs", "repo_id": "candle", "token_count": 2094 }
20
//! Types for elements that can be stored and manipulated using tensors. #![allow(clippy::redundant_closure_call)] use crate::backend::BackendStorage; use crate::{CpuStorage, CpuStorageRef, Error, Result}; /// The different types of elements allowed in tensors. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub en...
candle/candle-core/src/dtype.rs/0
{ "file_path": "candle/candle-core/src/dtype.rs", "repo_id": "candle", "token_count": 3099 }
21
#![allow(unused)] use super::GgmlDType; use crate::{Error, MetalDevice, MetalStorage, Result}; pub struct QMetalStorage { dtype: GgmlDType, device: MetalDevice, } impl QMetalStorage { pub fn zeros(_: &MetalDevice, _: usize, _: GgmlDType) -> Result<Self> { Err(Error::NotCompiledWithMetalSupport) ...
candle/candle-core/src/quantized/dummy_metal.rs/0
{ "file_path": "candle/candle-core/src/quantized/dummy_metal.rs", "repo_id": "candle", "token_count": 522 }
22
//! Tensors are N-dimensional matrixes of elements using a single data type. #![allow(clippy::redundant_closure_call)] use crate::backend::{BackendDevice, BackendStorage}; use crate::op::{BackpropOp, BinaryOp, CmpOp, Op, ReduceOp, UnaryOp}; use crate::scalar::TensorOrScalar; use crate::shape::{Dim, Dims}; use crate::{b...
candle/candle-core/src/tensor.rs/0
{ "file_path": "candle/candle-core/src/tensor.rs", "repo_id": "candle", "token_count": 48278 }
23
/// Regression test for pth files not loading on Windows. #[test] fn test_pth() { let tensors = candle_core::pickle::PthTensors::new("tests/test.pt", None).unwrap(); tensors.get("test").unwrap().unwrap(); } #[test] fn test_pth_with_key() { let tensors = candle_core::pickle::PthTensors::new("tests/t...
candle/candle-core/tests/pth_tests.rs/0
{ "file_path": "candle/candle-core/tests/pth_tests.rs", "repo_id": "candle", "token_count": 440 }
24
//! The MNIST hand-written digit dataset. //! //! The files can be obtained from the following link: //! <http://yann.lecun.com/exdb/mnist/> use candle::{DType, Device, Error, Result, Tensor}; use hf_hub::{api::sync::Api, Repo, RepoType}; use parquet::file::reader::{FileReader, SerializedFileReader}; use std::fs::File;...
candle/candle-datasets/src/vision/mnist.rs/0
{ "file_path": "candle/candle-datasets/src/vision/mnist.rs", "repo_id": "candle", "token_count": 2133 }
25
# candle-clip Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on pairs of images with related texts. https://github.com/openai/CLIP https://github.com/huggingface/transformers/tree/f6fa0f0bf0796ac66f201f23bdb8585de1609add/src/transformers/models/clip ## Running on an example on cpu ``` $ ...
candle/candle-examples/examples/clip/README.md/0
{ "file_path": "candle/candle-examples/examples/clip/README.md", "repo_id": "candle", "token_count": 623 }
26
# candle-dinov2-reg4 [DINOv2-reg4](https://arxiv.org/abs/2309.16588) is the lastest version of DINOv2 with registers. In this example, it is used as an plant species classifier: the model returns the probability for the image to belong to each of the 7806 PlantCLEF2024 categories. ## Running some example ```bash # D...
candle/candle-examples/examples/dinov2reg4/README.md/0
{ "file_path": "candle/candle-examples/examples/dinov2reg4/README.md", "repo_id": "candle", "token_count": 466 }
27
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::fastvit; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { T8,...
candle/candle-examples/examples/fastvit/main.rs/0
{ "file_path": "candle/candle-examples/examples/fastvit/main.rs", "repo_id": "candle", "token_count": 1332 }
28
// https://github.com/karpathy/llama2.c #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use candle_transformers::models::llama2_c as model; use candle_transformers::models::llama2_c_weights as weights; use candle_transformers::models::quantized_llama2_c...
candle/candle-examples/examples/llama2-c/main.rs/0
{ "file_path": "candle/candle-examples/examples/llama2-c/main.rs", "repo_id": "candle", "token_count": 6004 }
29
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Error as E; use clap::{Parser, ValueEnum}; use candle::{DType, Tensor}; use candle_examples::token_output_stream::TokenOutputStream; use candle_nn::VarBuilder; use candle_transformers::models::...
candle/candle-examples/examples/marian-mt/main.rs/0
{ "file_path": "candle/candle-examples/examples/marian-mt/main.rs", "repo_id": "candle", "token_count": 2385 }
30
#![allow(dead_code)] // https://huggingface.co/facebook/musicgen-small/tree/main // https://github.com/huggingface/transformers/blob/cd4584e3c809bb9e1392ccd3fe38b40daba5519a/src/transformers/models/musicgen/modeling_musicgen.py // TODO: Add an offline mode. // TODO: Add a KV cache. #[cfg(feature = "mkl")] extern crate...
candle/candle-examples/examples/musicgen/main.rs/0
{ "file_path": "candle/candle-examples/examples/musicgen/main.rs", "repo_id": "candle", "token_count": 1151 }
31
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use std::io::Write; use std::path::PathBuf; use candle_transformers::models::quantized_t5 as t5; use anyhow::{Error as E, Result}; use candle::{Device, Tensor}; use candle_transformers::generation::LogitsP...
candle/candle-examples/examples/quantized-t5/main.rs/0
{ "file_path": "candle/candle-examples/examples/quantized-t5/main.rs", "repo_id": "candle", "token_count": 3631 }
32
# candle-replit-code: code completion specialized model. [replit-code-v1_5-3b](https://huggingface.co/replit/replit-code-v1_5-3b) is a language model specialized for code completion. This model uses 3.3B parameters in `bfloat16` (so the GPU version will only work on recent nvidia cards). ## Running some example ```b...
candle/candle-examples/examples/replit-code/README.md/0
{ "file_path": "candle/candle-examples/examples/replit-code/README.md", "repo_id": "candle", "token_count": 426 }
33
//! SAM: Segment Anything Model //! https://github.com/facebookresearch/segment-anything #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::DType; use candle_nn::VarBuilder; use candle_transformers::models::segment_anything::sam; use clap::Pars...
candle/candle-examples/examples/segment-anything/main.rs/0
{ "file_path": "candle/candle-examples/examples/segment-anything/main.rs", "repo_id": "candle", "token_count": 3137 }
34
## VGG Model Implementation This example demonstrates the implementation of VGG models (VGG13, VGG16, VGG19) using the Candle library. The VGG models are defined in `candle-transformers/src/models/vgg.rs`. The main function in `candle-examples/examples/vgg/main.rs` loads an image, selects the VGG model based on the p...
candle/candle-examples/examples/vgg/README.md/0
{ "file_path": "candle/candle-examples/examples/vgg/README.md", "repo_id": "candle", "token_count": 200 }
35
use candle::{Device, Result, Tensor}; pub const IMAGENET_MEAN: [f32; 3] = [0.485f32, 0.456, 0.406]; pub const IMAGENET_STD: [f32; 3] = [0.229f32, 0.224, 0.225]; /// Loads an image from disk using the image crate at the requested resolution, /// using the given std and mean parameters. /// This returns a tensor with s...
candle/candle-examples/src/imagenet.rs/0
{ "file_path": "candle/candle-examples/src/imagenet.rs", "repo_id": "candle", "token_count": 13049 }
36
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/layout/layout.h" #include <cutlass/nu...
candle/candle-flash-attn/kernels/kernel_traits.h/0
{ "file_path": "candle/candle-flash-attn/kernels/kernel_traits.h", "repo_id": "candle", "token_count": 7766 }
37
#include "binary_op_macros.cuh" #include<stdint.h> #if __CUDA_ARCH__ >= 800 BINARY_OP(__nv_bfloat16, badd_bf16, x + y) BINARY_OP(__nv_bfloat16, bdiv_bf16, x / y) BINARY_OP(__nv_bfloat16, bmul_bf16, x * y) BINARY_OP(__nv_bfloat16, bsub_bf16, x - y) BINARY_OP(__nv_bfloat16, bmaximum_bf16, maxg(x, y)) BINARY_OP(__nv_bflo...
candle/candle-kernels/src/binary.cu/0
{ "file_path": "candle/candle-kernels/src/binary.cu", "repo_id": "candle", "token_count": 2144 }
38
#include <metal_stdlib> METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; strided_i += (idx % dims[dim_idx]) * str...
candle/candle-metal-kernels/src/affine.metal/0
{ "file_path": "candle/candle-metal-kernels/src/affine.metal", "repo_id": "candle", "token_count": 1496 }
39
use candle_metal_kernels::{binary, call_binary_contiguous, call_binary_strided, Kernels}; use half::{bf16, f16}; use metal::objc::rc::autoreleasepool; use metal::{Device, MTLResourceOptions}; use rand; use std::any::type_name; use std::time::Instant; fn main() { let device = Device::system_default().unwrap(); ...
candle/candle-metal-kernels/tmp/binary.rs/0
{ "file_path": "candle/candle-metal-kernels/tmp/binary.rs", "repo_id": "candle", "token_count": 3149 }
40
//! Layers defined by closures. use candle::{Result, Tensor}; use std::sync::Arc; /// A layer defined by a simple closure. #[derive(Clone)] pub struct Func<'a> { #[allow(clippy::type_complexity)] f: Arc<dyn 'a + Fn(&Tensor) -> Result<Tensor> + Send + Sync>, } impl<'a> std::fmt::Debug for Func<'a> { fn fmt...
candle/candle-nn/src/func.rs/0
{ "file_path": "candle/candle-nn/src/func.rs", "repo_id": "candle", "token_count": 804 }
41
/* Equivalent PyTorch code. import torch from torch.nn.functional import group_norm t = torch.tensor( [[[-0.3034, 0.2726, -0.9659], [-1.1845, -1.3236, 0.0172], [ 1.9507, 1.2554, -0.8625], [ 1.0682, 0.3604, 0.3985], [-0.4957, -0.4461, -0.9721], [ 1.5157, -0....
candle/candle-nn/tests/group_norm.rs/0
{ "file_path": "candle/candle-nn/tests/group_norm.rs", "repo_id": "candle", "token_count": 2154 }
42
## Installation From the `candle-pyo3` directory, enable a virtual env where you will want the candle package to be installed then run. ```bash maturin develop -r python test.py ``` ## Generating Stub Files for Type Hinting For type hinting support, the `candle-pyo3` package requires `*.pyi` files. You can automa...
candle/candle-pyo3/README.md/0
{ "file_path": "candle/candle-pyo3/README.md", "repo_id": "candle", "token_count": 190 }
43
import candle from candle import Tensor from .module import Module from typing import Union, List, Tuple, Optional, Any _shape_t = Union[int, List[int]] import numbers class LayerNorm(Module): r"""Applies Layer Normalization over a mini-batch of inputs as described in the paper `Layer Normalization <https://...
candle/candle-pyo3/py_src/candle/nn/normalization.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/nn/normalization.py", "repo_id": "candle", "token_count": 803 }
44
import candle import torch # convert from candle tensor to torch tensor t = candle.randn((3, 512, 512)) torch_tensor = t.to_torch() print(torch_tensor) print(type(torch_tensor)) # convert from torch tensor to candle tensor t = torch.randn((3, 512, 512)) candle_tensor = candle.Tensor(t) print(candle_tensor) print(type...
candle/candle-pyo3/test_pytorch.py/0
{ "file_path": "candle/candle-pyo3/test_pytorch.py", "repo_id": "candle", "token_count": 126 }
45