Phorm.ai
OpenAccess-AI-Collective/axolotl

    how do i use a huggingface auth token in config

    To use a Hugging Face authentication token in a configuration for accessing gated models or datasets, you typically need to ensure that the token is correctly set in your environment or passed directly to the Hugging Face API calls. Here's how you can do it:

    Setting the Token in Your Environment

    1. Using Environment Variable:

      You can set the HF_HOME environment variable to the directory where your Hugging Face configurations and tokens are stored. More specifically, you can set the HUGGINGFACE_HUB_TOKEN environment variable to your token. This is the recommended way as it keeps your token secure and does not require hardcoding it into your scripts.

      export HUGGINGFACE_HUB_TOKEN='your_token_here'

      Add this line to your .bashrc, .zshrc, or equivalent shell configuration file to make the change permanent.

    2. Using Hugging Face CLI:

      If you have the Hugging Face CLI installed, you can log in via the command line, and it will automatically save your token in the correct location.

      huggingface-cli login

      After running this command, you will be prompted to enter your token.

    Using the Token in Configuration Files

    For some Hugging Face tools like transformers, datasets, or accelerate, you might need to specify the use of the token in configuration files or scripts. Here's how you can do it in different scenarios:

    1. Transformers:

      When using the transformers library, if the token is set as an environment variable as shown above, it will automatically be used when accessing gated models or datasets.

    2. Datasets:

      Similarly, for the datasets library, setting the token as an environment variable allows you to access gated datasets without additional configuration.

    3. Axolotl:

      For Axolotl, specifically in the context of using a configuration file for training or preprocessing, you might need to explicitly specify the use of an authentication token for certain operations, like pushing a dataset to the Hugging Face Hub. In the Axolotl configuration file, you can specify the hf_use_auth_token parameter:

      push_dataset_to_hub: your_dataset_repo_name hf_use_auth_token: true

      Ensure that the HUGGINGFACE_HUB_TOKEN environment variable is set, as Axolotl will use it to authenticate your operations on the Hub.

    Note:

    • Always keep your token secure and never hardcode it directly into your scripts or configuration files that might be shared or made public.
    • The exact method to use the token might vary slightly depending on the specific library or tool from Hugging Face you are using. Always refer to the latest documentation for the most accurate and secure methods.
    Search results
    [huggingface/transformers] docs/README.md
    <!--- Copyright 2020 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/peft] docs/README.md
    <!--- 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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/accelerate] docs/README.md
    <!--- 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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/accelerate] CONTRIBUTING.md
    <!--- Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/transformers] CONTRIBUTING.md
    <!--- Copyright 2020 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/transformers] tests/test_modeling_tf_utils.py
    def setUpClass(cls): cls._token = TOKEN HfFolder.save_token(TOKEN)
    [huggingface/accelerate] examples/README.md
    <!--- Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/transformers] examples/README.md
    <!--- Copyright 2020 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/transformers] examples/legacy/README.md
    <!--- Copyright 2020 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/transformers] tests/test_modeling_utils.py
    def setUpClass(cls): cls.user = "huggingface-hub-ci" cls.token = os.getenv("HUGGINGFACE_PRODUCTION_USER_TOKEN", None) if cls.token is None: raise ValueError("Cannot run tests as secret isn't setup.") cls.api = HfApi(token=cls.token)
    [huggingface/transformers] src/transformers/tokenization_utils_fast.py
    logger = logging.get_logger(__name__) # Fast tokenizers (provided by HuggingFace tokenizer's library) can be saved in a single file TOKENIZER_FILE = "tokenizer.json" SPECIAL_TOKENS_MAP_FILE = "special_tokens_map.json" TOKENIZER_CONFIG_FILE = "tokenizer_config.json" # Slow tokenizers have an additional added tokens files ADDED_TOKENS_FILE = "added_tokens.json"
    [huggingface/transformers] tests/test_feature_extraction_utils.py
    def setUpClass(cls): cls._token = TOKEN HfFolder.save_token(TOKEN)
    [openaccess-ai-collective/axolotl] src/axolotl/cli/__init__.py
    def check_user_token(): # Skip check if HF_HUB_OFFLINE is set to True if os.getenv("HF_HUB_OFFLINE") == "1": LOG.info( "Skipping HuggingFace token verification because HF_HUB_OFFLINE is set to True. Only local files will be used." ) return True # Verify if token is valid api = HfApi() try: user_info = api.whoami() return bool(user_info) except LocalTokenNotFoundError: LOG.warning( "Error verifying HuggingFace token. Remember to log in using `huggingface-cli login` and get your access token from https://huggingface.co/settings/tokens if you want to use gated models or datasets." ) return False
    [huggingface/transformers] docs/source/en/internal/tokenization_utils.md
    <!--Copyright 2020 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/transformers] templates/adding_a_missing_tokenization_test/README.md
    <!--- Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->

    This folder contains a template to add a tokenization test.

    [huggingface/transformers] tests/generation/test_configuration_utils.py
    def setUpClass(cls): cls._token = TOKEN HfFolder.save_token(TOKEN)
    [huggingface/accelerate] docker/README.md
    <!--- 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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
    [huggingface/peft] examples/boft_dreambooth/utils/args_loader.py
    def get_full_repo_name(model_id: str, organization: Optional[str] = None, token: Optional[str] = None): if token is None: token = HfFolder.get_token() if organization is None: username = whoami(token)["name"] return f"{username}/{model_id}" else: return f"{organization}/{model_id}"
    [huggingface/accelerate] src/accelerate/commands/config/config_args.py
    hf_cache_home = os.path.expanduser( os.environ.get("HF_HOME", os.path.join(os.environ.get("XDG_CACHE_HOME", "~/.cache"), "huggingface")) ) cache_dir = os.path.join(hf_cache_home, "accelerate") default_json_config_file = os.path.join(cache_dir, "default_config.yaml") default_yaml_config_file = os.path.join(cache_dir, "default_config.yaml")
    [huggingface/peft] examples/hra_dreambooth/README.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/accelerate] README.md
    <!--- Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <p align="center"> <br> <img src="https://raw.githubusercontent.com/huggingface/accelerate/main/docs/source/imgs/accelerate_logo.png" width="400"/> <br> <p> <p align="center"> <!-- Uncomment when CircleCI is set up <a href="https://circleci.com/gh/huggingface/accelerate"><img alt="Build" src="https://img.shields.io/circleci/build/github/huggingface/transformers/master"></a> --> <a href="https://github.com/huggingface/accelerate/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/huggingface/accelerate.svg?color=blue"></a> <a href="https://huggingface.co/docs/accelerate/index.html"><img alt="Documentation" src="https://img.shields.io/website/http/huggingface.co/docs/accelerate/index.html.svg?down_color=red&down_message=offline&up_message=online"></a> <a href="https://github.com/huggingface/accelerate/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/accelerate.svg"></a> <a href="https://github.com/huggingface/accelerate/blob/main/CODE_OF_CONDUCT.md"><img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg"></a> </p> <h3 align="center"> <p>Run your *raw* PyTorch training script on any kind of device </h3> <h3 align="center"> <a href="https://hf.co/course"><img src="https://raw.githubusercontent.com/huggingface/accelerate/main/docs/source/imgs/course_banner.png"></a> </h3>
    [huggingface/accelerate] docs/source/usage_guides/ddp_comm_hook.md
    <!-- Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/peft] docs/source/developer_guides/contributing.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/peft] docs/source/developer_guides/low_level_api.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [openaccess-ai-collective/axolotl] src/axolotl/utils/models.py
    def load_tokenizer(cfg): model_config = load_model_config(cfg) tokenizer_kwargs = {} use_fast = True # this is the default if cfg.tokenizer_use_fast is not None: use_fast = cfg.tokenizer_use_fast if cfg.tokenizer_legacy is not None: # True is the default w/ https://github.com/huggingface/transformers/pull/25224 tokenizer_kwargs["legacy"] = cfg.tokenizer_legacy tokenizer_cls = AutoTokenizer if cfg.tokenizer_type: tokenizer_cls = getattr(transformers, cfg.tokenizer_type) tokenizer = tokenizer_cls.from_pretrained( cfg.tokenizer_config, trust_remote_code=cfg.trust_remote_code or False, use_fast=use_fast, **tokenizer_kwargs, ) if ( tokenizer.__class__.__name__ in [ "LlamaTokenizer", "LlamaTokenizerFast", "CodeLlamaTokenizer", "CodeLlamaTokenizerFast", ] and hasattr(tokenizer, "pad_token") and not tokenizer.pad_token ): # set a pad_token, but use eos_token so we don't add a new token tokenizer.pad_token = LLAMA_DEFAULT_EOS_TOKEN if tokenizer.__class__.__name__ == "GPTNeoXTokenizerFast": tokenizer.add_special_tokens({"pad_token": "[PAD]"}) os.environ["TOKENIZERS_PARALLELISM"] = "false" # Mistral's official FA implementation requires left padding if cfg.is_mistral_derived_model and cfg.flash_attention and not cfg.sample_packing: tokenizer.padding_side = "left" # Qwen base only has single token, so we need to set the special tokens if cfg.is_qwen_derived_model: token_ids = ["bos_token_id", "eos_token_id", "pad_token_id", "unk_token_id"] for attr_name in token_ids: if getattr(tokenizer, attr_name) is None: setattr(tokenizer, attr_name, tokenizer.eod_id) token_names = ["bos_token", "eos_token", "pad_token", "unk_token"] for attr_name in token_names: if getattr(tokenizer, attr_name) is None: setattr(tokenizer, attr_name, "<|endoftext|>") additional_special_tokens = None if cfg.special_tokens: special_tokens = cfg.special_tokens.to_dict() additional_special_tokens = special_tokens.pop( "additional_special_tokens", None ) lora_modules_to_save = get_linear_embedding_layers(model_config.model_type) for k, val in special_tokens.items(): # check if new special token is not already in tokenizer and # is adapter training to make sure lora_modules_to_save is set # pylint: disable=too-many-boolean-expressions if ( (getattr(tokenizer, k) is None or getattr(tokenizer, k) != val) and (len(tokenizer.encode(val, add_special_tokens=False)) > 2) and cfg.adapter and ( not cfg.lora_modules_to_save or not all( x in cfg.lora_modules_to_save for x in lora_modules_to_save ) ) ): lora_modules_to_save = ", ".join( [f"`{x}`" for x in lora_modules_to_save] ) raise ValueError( f"Please set lora_modules_to_save to [{lora_modules_to_save}] when using an adapter and changing the special tokens." ) tokenizer.add_special_tokens( {k: AddedToken(val, rstrip=False, lstrip=False, normalized=False)} ) # If we add bos_token and eos_token, we need to update the post processor to # handle them correctly. # https://github.com/huggingface/transformers/pull/24132 bos_or_eos_in_special_tokens = ( "bos_token" in cfg.special_tokens and "eos_token" in cfg.special_tokens ) if ( tokenizer.__class__.__name__ in ( "LlamaTokenizerFast", "CodeLlamaTokenizerFast", ) and bos_or_eos_in_special_tokens ): tokenizer.update_post_processor() if cfg.tokens: tokenizer.add_tokens( [ AddedToken(token, rstrip=False, lstrip=False, normalized=False) for token in cfg.tokens ] ) # Additional special tokens are a List, and need to be treated differently than regular special # tokens. We add them after we have called `add_tokens` in case these additional special tokens # are new tokens. # # Usage: # # ```py # special_tokens: # additional_special_tokens: ["<|im_start|>", "<|im_end|>"] # ``` if additional_special_tokens is not None: tokenizer.add_special_tokens( {"additional_special_tokens": additional_special_tokens} ) with zero_only(): LOG.debug(f"EOS: {tokenizer.eos_token_id} / {tokenizer.eos_token}") LOG.debug(f"BOS: {tokenizer.bos_token_id} / {tokenizer.bos_token}") LOG.debug(f"PAD: {tokenizer.pad_token_id} / {tokenizer.pad_token}") LOG.debug(f"UNK: {tokenizer.unk_token_id} / {tokenizer.unk_token}") if cfg.chat_template: chat_template_string = chat_templates(cfg.chat_template) if cfg.default_system_message and cfg.chat_template == "chatml": chat_template_string = chat_template_string.replace( "You are a helpful assistant.", cfg.default_system_message ) tokenizer.chat_template = chat_template_string else: LOG.info( "No Chat template selected. Consider adding a chat template for easier inference." ) return tokenizer
    [huggingface/peft] docs/source/package_reference/adapter_utils.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/peft] docs/source/package_reference/loha.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/peft] docs/source/conceptual_guides/adapter.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/peft] examples/boft_controlnet/utils/args_loader.py
    def get_full_repo_name(model_id: str, organization: Optional[str] = None, token: Optional[str] = None): if token is None: token = HfFolder.get_token() if organization is None: username = whoami(token)["name"] return f"{username}/{model_id}" else: return f"{organization}/{model_id}"
    [openaccess-ai-collective/axolotl] README.md

    Train

    Run

    accelerate launch -m axolotl.cli.train your_config.yml

    [!TIP] You can also reference a config file that is hosted on a public URL, for example accelerate launch -m axolotl.cli.train https://yourdomain.com/your_config.yml

    Preprocess dataset

    You can optionally pre-tokenize dataset with the following before finetuning. This is recommended for large datasets.

    • Set dataset_prepared_path: to a local folder for saving and loading pre-tokenized dataset.
    • (Optional): Set push_dataset_to_hub: hf_user/repo to push it to Huggingface.
    • (Optional): Use --debug to see preprocessed examples.
    python -m axolotl.cli.preprocess your_config.yml

    Multi-GPU

    Below are the options available in axolotl for training with multiple GPUs. Note that DeepSpeed is the recommended multi-GPU option currently because FSDP may experience loss instability.

    DeepSpeed

    Deepspeed is an optimization suite for multi-gpu systems allowing you to train much larger models than you might typically be able to fit into your GPU's VRAM. More information about the various optimization types for deepspeed is available at https://huggingface.co/docs/accelerate/main/en/usage_guides/deepspeed#what-is-integrated

    We provide several default deepspeed JSON configurations for ZeRO stage 1, 2, and 3.

    deepspeed: deepspeed_configs/zero1.json
    accelerate launch -m axolotl.cli.train examples/llama-2/config.yml --deepspeed deepspeed_configs/zero1.json
    FSDP
    • llama FSDP
    fsdp: - full_shard - auto_wrap fsdp_config: fsdp_offload_params: true fsdp_state_dict_type: FULL_STATE_DICT fsdp_transformer_layer_cls_to_wrap: LlamaDecoderLayer
    FSDP + QLoRA

    Axolotl supports training with FSDP and QLoRA, see these docs for more information.

    Weights & Biases Logging

    Make sure your WANDB_API_KEY environment variable is set (recommended) or you login to wandb with wandb login.

    • wandb options
    wandb_mode: wandb_project: wandb_entity: wandb_watch: wandb_name: wandb_log_model:
    Special Tokens

    It is important to have special tokens like delimiters, end-of-sequence, beginning-of-sequence in your tokenizer's vocabulary. This will help you avoid tokenization issues and help your model train better. You can do this in axolotl like this:

    special_tokens: bos_token: "<s>" eos_token: "</s>" unk_token: "<unk>" tokens: # these are delimiters - "<|im_start|>" - "<|im_end|>"

    When you include these tokens in your axolotl config, axolotl adds these tokens to the tokenizer's vocabulary.

    [huggingface/peft] docs/source/developer_guides/troubleshooting.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/accelerate] docs/source/basic_tutorials/troubleshooting.md
    <!--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 applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [openaccess-ai-collective/axolotl] src/axolotl/utils/config/models/input/v0_4_1/__init__.py
    def check_push_ds_auth(cls, data): if ( data.get("push_dataset_to_hub") and data.get("hf_use_auth_token") is not True ): raise ValueError( "Require cfg.hf_use_auth_token to be True for push_dataset_to_hub" ) return data
    [huggingface/peft] examples/olora_finetuning/olora_finetuning.py
    def tokenize(prompt, add_eos_token=True): result = tokenizer( prompt, truncation=True, max_length=cutoff_len, padding=False, return_tensors=None, ) if ( result["input_ids"][-1] != tokenizer.eos_token_id and len(result["input_ids"]) < cutoff_len and add_eos_token ): result["input_ids"].append(tokenizer.eos_token_id) result["attention_mask"].append(1) result["labels"] = result["input_ids"].copy() return result
    [huggingface/accelerate] docs/source/usage_guides/fsdp.md
    <!--Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
    [huggingface/accelerate] src/accelerate/commands/estimate.py
    def create_empty_model(model_name: str, library_name: str, trust_remote_code: bool = False, access_token: str = None): """ Creates an empty model from its parent library on the `Hub` to calculate the overall memory consumption. Args: model_name (`str`): The model name on the Hub library_name (`str`): The library the model has an integration with, such as `transformers`. Will be used if `model_name` has no metadata on the Hub to determine the library. trust_remote_code (`bool`, `optional`, defaults to `False`): Whether or not to allow for custom models defined on the Hub in their own modeling files. This option should only be set to `True` for repositories you trust and in which you have read the code, as it will execute code present on the Hub on your local machine. access_token (`str`, `optional`, defaults to `None`): The access token to use to access private or gated models on the Hub. (for use on the Gradio app) Returns: `torch.nn.Module`: The torch model that has been initialized on the `meta` device. """ model_info = verify_on_hub(model_name, access_token) # Simplified errors if model_info == "gated": raise GatedRepoError( f"Repo for model `{model_name}` is gated. You must be authenticated to access it. Please run `huggingface-cli login`." ) elif model_info == "repo": raise RepositoryNotFoundError( f"Repo for model `{model_name}` does not exist on the Hub. If you are trying to access a private repo," " make sure you are authenticated via `huggingface-cli login` and have access." ) if library_name is None: library_name = getattr(model_info, "library_name", False) if not library_name: raise ValueError( f"Model `{model_name}` does not have any library metadata on the Hub, please manually pass in a `--library_name` to use (such as `transformers`)" ) if library_name == "transformers": if not is_transformers_available(): raise ImportError( f"To check `{model_name}`, `transformers` must be installed. Please install it via `pip install transformers`" ) print(f"Loading pretrained config for `{model_name}` from `transformers`...") if model_info.config is None: raise RuntimeError(f"Tried to load `{model_name}` with `transformers` but it does not have any metadata.") auto_map = model_info.config.get("auto_map", False) config = AutoConfig.from_pretrained(model_name, trust_remote_code=trust_remote_code, token=access_token) with init_empty_weights(): # remote code could specify a specific `AutoModel` class in the `auto_map` constructor = AutoModel if isinstance(auto_map, dict): value = None for key in auto_map.keys(): if key.startswith("AutoModelFor"): value = key break if value is not None: constructor = getattr(transformers, value) model = constructor.from_config(config, trust_remote_code=trust_remote_code) elif library_name == "timm": if not is_timm_available(): raise ImportError( f"To check `{model_name}`, `timm` must be installed. Please install it via `pip install timm`" ) print(f"Loading pretrained config for `{model_name}` from `timm`...") with init_empty_weights(): model = timm.create_model(model_name, pretrained=False) else: raise ValueError( f"Library `{library_name}` is not supported yet, please open an issue on GitHub for us to add support." ) return model
    [huggingface/peft] examples/conditional_generation/peft_adalora_seq2seq.py
    def preprocess_function(examples): inputs = examples[text_column] targets = examples[label_column] model_inputs = tokenizer(inputs, max_length=max_length, padding="max_length", truncation=True, return_tensors="pt") labels = tokenizer(targets, max_length=3, padding="max_length", truncation=True, return_tensors="pt") labels = labels["input_ids"] labels[labels == tokenizer.pad_token_id] = -100 model_inputs["labels"] = labels return model_inputs
    [openaccess-ai-collective/axolotl] README.md

    Config

    See examples for quick start. It is recommended to duplicate and modify to your needs. The most important options are:

    • model

      base_model: ./llama-7b-hf # local or huggingface repo

      Note: The code will load the right architecture.

    • dataset

      datasets: # huggingface repo - path: vicgalle/alpaca-gpt4 type: alpaca # huggingface repo with specific configuration/subset - path: EleutherAI/pile name: enron_emails type: completion # format from earlier field: text # Optional[str] default: text, field to use for completion data # huggingface repo with multiple named configurations/subsets - path: bigcode/commitpackft name: - ruby - python - typescript type: ... # unimplemented custom format # fastchat conversation # See 'conversation' options: https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py - path: ... type: sharegpt conversation: chatml # default: vicuna_v1.1 # local - path: data.jsonl # or json ds_type: json # see other options below type: alpaca # dataset with splits, but no train split - path: knowrohit07/know_sql type: context_qa.load_v2 train_on_split: validation # loading from s3 or gcs # s3 creds will be loaded from the system default and gcs only supports public access - path: s3://path_to_ds # Accepts folder with arrow/parquet or file path like above. Supports s3, gcs. ... # Loading Data From a Public URL # - The file format is `json` (which includes `jsonl`) by default. For different formats, adjust the `ds_type` option accordingly. - path: https://some.url.com/yourdata.jsonl # The URL should be a direct link to the file you wish to load. URLs must use HTTPS protocol, not HTTP. ds_type: json # this is the default, see other options below.
    • loading

      load_in_4bit: true load_in_8bit: true bf16: auto # require >=ampere, auto will detect if your GPU supports this and choose automatically. fp16: # leave empty to use fp16 when bf16 is 'auto'. set to false if you want to fallback to fp32 tf32: true # require >=ampere bfloat16: true # require >=ampere, use instead of bf16 when you don't want AMP (automatic mixed precision) float16: true # use instead of fp16 when you don't want AMP

      Note: Repo does not do 4-bit quantization.

    • lora

      adapter: lora # 'qlora' or leave blank for full finetune lora_r: 8 lora_alpha: 16 lora_dropout: 0.05 lora_target_modules: - q_proj - v_proj

    All Config Options

    See these docs for all config options.

    [openaccess-ai-collective/axolotl] docs/config.qmd
    optim_target_modules:
    # - self_attn  # for llama
    # - mlp
    
    # Specify weight decay
    weight_decay:
    # adamw hyperparams
    adam_beta1:
    adam_beta2:
    adam_epsilon:
    # Gradient clipping max norm
    max_grad_norm:
    
    # Augmentation techniques
    # NEFT https://arxiv.org/abs/2310.05914, set this to a number (paper default is 5) to add noise to embeddings
    # currently only supported on Llama and Mistral
    neftune_noise_alpha:
    
    # Whether to bettertransformers
    flash_optimum:
    # Whether to use xformers attention patch https://github.com/facebookresearch/xformers:
    xformers_attention:
    # Whether to use flash attention patch https://github.com/Dao-AILab/flash-attention:
    flash_attention:
    flash_attn_cross_entropy:  # Whether to use flash-attention cross entropy implementation - advanced use only
    flash_attn_rms_norm:  # Whether to use flash-attention rms norm implementation - advanced use only
    flash_attn_fuse_qkv: # Whether to fuse QKV into a single operation
    flash_attn_fuse_mlp: # Whether to fuse part of the MLP into a single operation
    # Whether to use scaled-dot-product attention
    # https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html
    sdp_attention:
    # Shifted-sparse attention (only llama) - https://arxiv.org/pdf/2309.12307.pdf
    s2_attention:
    # Resume from a specific checkpoint dir
    resume_from_checkpoint:
    # If resume_from_checkpoint isn't set and you simply want it to start where it left off.
    # Be careful with this being turned on between different models.
    auto_resume_from_checkpoints: false
    
    # Don't mess with this, it's here for accelerate and torchrun
    local_rank:
    
    # Add or change special tokens.
    # If you add tokens here, you don't need to add them to the `tokens` list.
    special_tokens:
      # bos_token: "<s>"
      # eos_token: "</s>"
      # unk_token: "<unk>"
      # pad_token: "[PAD]"
    
    # Add extra tokens.
    tokens:
    
    # FSDP
    fsdp:
    fsdp_config:
    
    # Deepspeed config path. e.g., deepspeed_configs/zero3.json
    deepspeed:
    
    # Advanced DDP Arguments
    ddp_timeout:
    ddp_bucket_cap_mb:
    ddp_broadcast_buffers:
    
    # Path to torch distx for optim 'adamw_anyprecision'
    torchdistx_path:
    
    # Set to HF dataset for type: 'completion' for streaming instead of pre-tokenize
    pretraining_dataset:
    
    # Debug mode
    debug:
    
    # Seed
    seed:
    
    # Allow overwrite yml config using from cli
    strict:
    
    [huggingface/accelerate] src/accelerate/commands/launch.py
    def sagemaker_launcher(sagemaker_config: SageMakerConfig, args): if not is_sagemaker_available(): raise ImportError( "Please install sagemaker to be able to launch training on Amazon SageMaker with `pip install accelerate[sagemaker]`" ) if args.module or args.no_python: raise ValueError( "SageMaker requires a python training script file and cannot be used with --module or --no_python" ) from sagemaker.huggingface import HuggingFace args, sagemaker_inputs = prepare_sagemager_args_inputs(sagemaker_config, args) huggingface_estimator = HuggingFace(**args) huggingface_estimator.fit(inputs=sagemaker_inputs) print(f"You can find your model data at: {huggingface_estimator.model_data}")
    [huggingface/peft] examples/conditional_generation/peft_adalora_seq2seq.py
    # data preprocessing tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
    [openaccess-ai-collective/axolotl] examples/jeopardy-bot/config.yml
    base_model: huggyllama/llama-7b model_type: LlamaForCausalLM tokenizer_type: LlamaTokenizer load_in_8bit: false datasets: - path: openaccess-ai-collective/jeopardy type: jeopardy dataset_prepared_path: val_set_size: 0.02 adapter: lora_model_dir: sequence_len: 512 max_packed_sequence_len: lora_r: lora_alpha: lora_dropout: lora_target_modules: lora_fan_in_fan_out: false wandb_project: wandb_entity: wandb_watch: wandb_name: wandb_log_model: output_dir: ./outputs/jeopardy-bot-7b gradient_accumulation_steps: 1 micro_batch_size: 1 num_epochs: 4 optimizer: adamw_bnb_8bit torchdistx_path: lr_scheduler: cosine learning_rate: 0.00003 train_on_inputs: false group_by_length: false bf16: auto tf32: true early_stopping_patience: resume_from_checkpoint: local_rank: logging_steps: 5 xformers_attention: true flash_attention: gptq_groupsize: gptq_model_v1: warmup_steps: 20 evals_per_epoch: 4 saves_per_epoch: 1 debug: deepspeed: weight_decay: 0.1 fsdp: fsdp_config: tokens: bos_token: "<s>" eos_token: "</s>" unk_token: "<unk>"
    [openaccess-ai-collective/axolotl] src/axolotl/prompt_strategies/alpaca_w_system.py
    def load(tokenizer, cfg): return load_chat(tokenizer, cfg)
    [huggingface/peft] examples/fp4_finetuning/finetune_fp4_opt_bnb_peft.py
    trainer = transformers.Trainer( model=model, train_dataset=data["train"], args=transformers.TrainingArguments( per_device_train_batch_size=4, gradient_accumulation_steps=4, warmup_steps=10, max_steps=20, learning_rate=3e-4, fp16=True, logging_steps=1, output_dir="outputs", ), data_collator=transformers.DataCollatorForLanguageModeling(tokenizer, mlm=False), ) model.config.use_cache = False
    [huggingface/accelerate] src/accelerate/big_modeling.py
    def wrapper(*args, **kwargs): warning_msg = "You shouldn't move a model that is dispatched using accelerate hooks." if str(fn.__name__) == "to": to_device = torch._C._nn._parse_to(*args, **kwargs)[0] if to_device is not None: logger.warning(warning_msg) else: logger.warning(warning_msg) for param in model.parameters(): if param.device == torch.device("meta"): raise RuntimeError("You can't move a model that has some modules offloaded to cpu or disk.") return fn(*args, **kwargs)
    [openaccess-ai-collective/axolotl] src/axolotl/prompt_strategies/alpaca_chat.py
    def load_camel_ai(tokenizer, cfg): return CamelAIPromptTokenizingStrategy( AlpacaChatPrompter(), tokenizer, cfg.train_on_inputs, cfg.sequence_len, )
    [openaccess-ai-collective/axolotl] examples/falcon/config-7b.yml
    base_model: tiiuae/falcon-7b trust_remote_code: true model_type: AutoModelForCausalLM tokenizer_type: AutoTokenizer load_in_8bit: false load_in_4bit: false gptq: false strict: false push_dataset_to_hub: datasets: - path: teknium/GPT4-LLM-Cleaned type: alpaca:chat dataset_prepared_path: val_set_size: 0.05 adapter: lora_model_dir: sequence_len: 2048 max_packed_sequence_len: lora_r: 64 lora_alpha: 32 lora_dropout: 0.0 lora_target_modules: lora_target_linear: true lora_fan_in_fan_out: wandb_project: wandb_entity: wandb_watch: wandb_name: wandb_log_model: output_dir: ./outputs/falcon-7b batch_size: 2 micro_batch_size: 1 num_epochs: 4 optimizer: adamw_bnb_8bit torchdistx_path: lr_scheduler: cosine learning_rate: 0.00003 train_on_inputs: false group_by_length: false bf16: auto fp16: tf32: true gradient_checkpointing: true early_stopping_patience: resume_from_checkpoint: local_rank: logging_steps: 1 xformers_attention: true flash_attention: gptq_groupsize: gptq_model_v1: warmup_steps: 40 evals_per_epoch: 4 saves_per_epoch: 1 debug: deepspeed: weight_decay: 0.0 fsdp: fsdp_config: special_tokens: pad_token: "<|endoftext|>" bos_token: "<|endoftext|>" eos_token: "<|endoftext|>"
    [openaccess-ai-collective/axolotl] examples/falcon/config-7b-lora.yml
    base_model: tiiuae/falcon-7b trust_remote_code: true model_type: AutoModelForCausalLM tokenizer_type: AutoTokenizer load_in_8bit: true load_in_4bit: false gptq: false strict: false push_dataset_to_hub: datasets: - path: teknium/GPT4-LLM-Cleaned type: alpaca:chat dataset_prepared_path: val_set_size: 0.05 adapter: lora lora_model_dir: sequence_len: 2048 max_packed_sequence_len: lora_r: 16 lora_alpha: 32 lora_dropout: 0.0 lora_target_modules: lora_target_linear: true lora_fan_in_fan_out: wandb_project: wandb_entity: wandb_watch: wandb_name: wandb_log_model: output_dir: ./outputs/falcon-7b batch_size: 2 micro_batch_size: 1 num_epochs: 4 optimizer: adamw_bnb_8bit torchdistx_path: lr_scheduler: cosine learning_rate: 0.00003 train_on_inputs: false group_by_length: false bf16: auto fp16: tf32: true gradient_checkpointing: true early_stopping_patience: resume_from_checkpoint: local_rank: logging_steps: 1 xformers_attention: true flash_attention: gptq_groupsize: gptq_model_v1: warmup_steps: 40 evals_per_epoch: 4 saves_per_epoch: 1 debug: deepspeed: weight_decay: 0.0 fsdp: fsdp_config: special_tokens: pad_token: "<|endoftext|>" bos_token: "<|endoftext|>" eos_token: "<|endoftext|>"
    [huggingface/accelerate] src/accelerate/commands/estimate.py
    def verify_on_hub(repo: str, token: str = None): "Verifies that the model is on the hub and returns the model info." try: return model_info(repo, token=token) except GatedRepoError: return "gated" except RepositoryNotFoundError: return "repo"
    [openaccess-ai-collective/axolotl] examples/redpajama/config-3b.yml
    base_model: togethercomputer/RedPajama-INCITE-Chat-3B-v1 model_type: GPTNeoXForCausalLM tokenizer_type: AutoTokenizer trust_remote_code: load_in_8bit: false datasets: - path: vicgalle/alpaca-gpt4 type: alpaca dataset_prepared_path: val_set_size: 0.02 adapter: lora_model_dir: sequence_len: 2048 max_packed_sequence_len: lora_r: 8 lora_alpha: 16 lora_dropout: 0.05 lora_target_modules: - q_proj - v_proj lora_fan_in_fan_out: false wandb_project: redpajama-alpaca-3b wandb_entity: wandb_watch: wandb_name: wandb_log_model: output_dir: ./outputs/redpajama-alpaca-3b batch_size: 4 micro_batch_size: 1 num_epochs: 4 optimizer: adamw_bnb_8bit torchdistx_path: lr_scheduler: cosine learning_rate: 0.0000002 train_on_inputs: false group_by_length: false bf16: auto tf32: true early_stopping_patience: resume_from_checkpoint: local_rank: logging_steps: 5 xformers_attention: flash_attention: gptq_groupsize: gptq_model_v1: warmup_steps: 20 evals_per_epoch: 4 saves_per_epoch: 1 debug: deepspeed: weight_decay: 0.0001 fsdp: fsdp_config: tokens: pad_token: "<|padding|>" bos_token: "<|endoftext|>" eos_token: "<|endoftext|>" unk_token: "<|endoftext|>"
    [openaccess-ai-collective/axolotl] src/axolotl/prompt_strategies/metharme.py
    LOG = logging.getLogger("axolotl") IGNORE_TOKEN_ID = -100
    [openaccess-ai-collective/axolotl] docs/dataset-formats/tokenized.qmd
    ---
    title: Custom Pre-Tokenized Dataset
    description: How to use a custom pre-tokenized dataset.
    order: 5
    ---
    
    - Pass an empty `type:` in your axolotl config.
    - Columns in Dataset must be exactly `input_ids`, `attention_mask`, `labels`
    - To indicate that a token should be ignored during training, set its corresponding label to `-100`.
    - Do not add BOS/EOS. Axolotl will add them for you based on the default tokenizer for the model you're using.
    - For pretraining, do not truncate/pad documents to the context window length.
    - For instruction training, documents must be truncated/padded as desired.
    
    Sample config:
    
    ```{.yaml filename="config.yml"}
    datasets:
      - path: /path/to/your/file.jsonl
        ds_type: json
        type:
    

    Sample jsonl:

    {"input_ids":[271,299,99],"attention_mask":[1,1,1],"labels":[271,-100,99]} {"input_ids":[87,227,8383,12],"attention_mask":[1,1,1,1],"labels":[87,227,8383,12]}
    [openaccess-ai-collective/axolotl] README.md

    Advanced Setup

    Environment

    Docker

    docker run --gpus '"all"' --rm -it winglian/axolotl:main-latest

    Or run on the current files for development:

    docker compose up -d

    [!Tip] If you want to debug axolotl or prefer to use Docker as your development environment, see the debugging guide's section on Docker.

    <details> <summary>Docker advanced</summary>

    A more powerful Docker command to run would be this:

    docker run --privileged --gpus '"all"' --shm-size 10g --rm -it --name axolotl --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 --mount type=bind,src="${PWD}",target=/workspace/axolotl -v ${HOME}/.cache/huggingface:/root/.cache/huggingface winglian/axolotl:main-latest

    It additionally:

    • Prevents memory issues when running e.g. deepspeed (e.g. you could hit SIGBUS/signal 7 error) through --ipc and --ulimit args.
    • Persists the downloaded HF data (models etc.) and your modifications to axolotl code through --mount/-v args.
    • The --name argument simply makes it easier to refer to the container in vscode (Dev Containers: Attach to Running Container...) or in your terminal.
    • The --privileged flag gives all capabilities to the container.
    • The --shm-size 10g argument increases the shared memory size. Use this if you see exitcode: -7 errors using deepspeed.

    More information on nvidia website

    </details>

    Conda/Pip venv

    1. Install python >=3.10

    2. Install pytorch stable https://pytorch.org/get-started/locally/

    3. Install Axolotl along with python dependencies

      pip3 install packaging pip3 install -e '.[flash-attn,deepspeed]'
    4. (Optional) Login to Huggingface to use gated models/datasets.

      huggingface-cli login

      Get the token at huggingface.co/settings/tokens

    Cloud GPU

    For cloud GPU providers that support docker images, use winglian/axolotl-cloud:main-latest

    Bare Metal Cloud GPU

    LambdaLabs
    <details> <summary>Click to Expand</summary>
    1. Install python
    sudo apt update sudo apt install -y python3.10 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 sudo update-alternatives --config python # pick 3.10 if given option python -V # should be 3.10
    1. Install pip
    wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
    1. Install Pytorch https://pytorch.org/get-started/locally/

    2. Follow instructions on quickstart.

    3. Run

    pip3 install protobuf==3.20.3 pip3 install -U --ignore-installed requests Pillow psutil scipy
    1. Set path
    export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
    </details>
    GCP
    <details> <summary>Click to Expand</summary>

    Use a Deeplearning linux OS with cuda and pytorch installed. Then follow instructions on quickstart.

    Make sure to run the below to uninstall xla.

    pip uninstall -y torch_xla[tpu]
    </details>

    Windows

    Please use WSL or Docker!

    Mac

    Use the below instead of the install method in QuickStart.

    pip3 install -e '.'
    

    More info: mac.md

    Google Colab

    Please use this example notebook.

    Launching on public clouds via SkyPilot

    To launch on GPU instances (both on-demand and spot instances) on 7+ clouds (GCP, AWS, Azure, OCI, and more), you can use SkyPilot:

    pip install "skypilot-nightly[gcp,aws,azure,oci,lambda,kubernetes,ibm,scp]" # choose your clouds sky check

    Get the example YAMLs of using Axolotl to finetune mistralai/Mistral-7B-v0.1:

    git clone https://github.com/skypilot-org/skypilot.git
    cd skypilot/llm/axolotl
    

    Use one command to launch:

    # On-demand HF_TOKEN=xx sky launch axolotl.yaml --env HF_TOKEN # Managed spot (auto-recovery on preemption) HF_TOKEN=xx BUCKET=<unique-name> sky spot launch axolotl-spot.yaml --env HF_TOKEN --env BUCKET

    Launching on public clouds via dstack

    To launch on GPU instance (both on-demand and spot instances) on public clouds (GCP, AWS, Azure, Lambda Labs, TensorDock, Vast.ai, and CUDO), you can use dstack.

    Write a job description in YAML as below:

    # dstack.yaml type: task image: winglian/axolotl-cloud:main-20240429-py3.11-cu121-2.2.2 env: - HUGGING_FACE_HUB_TOKEN - WANDB_API_KEY commands: - accelerate launch -m axolotl.cli.train config.yaml ports: - 6006 resources: gpu: memory: 24GB.. count: 2

    then, simply run the job with dstack run command. Append --spot option if you want spot instance. dstack run command will show you the instance with cheapest price across multi cloud services:

    pip install dstack HUGGING_FACE_HUB_TOKEN=xxx WANDB_API_KEY=xxx dstack run . -f dstack.yaml # --spot

    For further and fine-grained use cases, please refer to the official dstack documents and the detailed description of axolotl example on the official repository.

    Dataset

    Axolotl supports a variety of dataset formats. It is recommended to use a JSONL. The schema of the JSONL depends upon the task and the prompt template you wish to use. Instead of a JSONL, you can also use a HuggingFace dataset with columns for each JSONL field.

    See these docs for more information on how to use different dataset formats.

    Config

    See examples for quick start. It is recommended to duplicate and modify to your needs. The most important options are:

    • model

      base_model: ./llama-7b-hf # local or huggingface repo

      Note: The code will load the right architecture.

    • dataset

      datasets: # huggingface repo - path: vicgalle/alpaca-gpt4 type: alpaca # huggingface repo with specific configuration/subset - path: EleutherAI/pile name: enron_emails type: completion # format from earlier field: text # Optional[str] default: text, field to use for completion data # huggingface repo with multiple named configurations/subsets - path: bigcode/commitpackft name: - ruby - python - typescript type: ... # unimplemented custom format # fastchat conversation # See 'conversation' options: https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py - path: ... type: sharegpt conversation: chatml # default: vicuna_v1.1 # local - path: data.jsonl # or json ds_type: json # see other options below type: alpaca # dataset with splits, but no train split - path: knowrohit07/know_sql type: context_qa.load_v2 train_on_split: validation # loading from s3 or gcs # s3 creds will be loaded from the system default and gcs only supports public access - path: s3://path_to_ds # Accepts folder with arrow/parquet or file path like above. Supports s3, gcs. ... # Loading Data From a Public URL # - The file format is `json` (which includes `jsonl`) by default. For different formats, adjust the `ds_type` option accordingly. - path: https://some.url.com/yourdata.jsonl # The URL should be a direct link to the file you wish to load. URLs must use HTTPS protocol, not HTTP. ds_type: json # this is the default, see other options below.
    • loading

      load_in_4bit: true load_in_8bit: true bf16: auto # require >=ampere, auto will detect if your GPU supports this and choose automatically. fp16: # leave empty to use fp16 when bf16 is 'auto'. set to false if you want to fallback to fp32 tf32: true # require >=ampere bfloat16: true # require >=ampere, use instead of bf16 when you don't want AMP (automatic mixed precision) float16: true # use instead of fp16 when you don't want AMP

      Note: Repo does not do 4-bit quantization.

    • lora

      adapter: lora # 'qlora' or leave blank for full finetune lora_r: 8 lora_alpha: 16 lora_dropout: 0.05 lora_target_modules: - q_proj - v_proj

    All Config Options

    See these docs for all config options.

    Train

    Run

    accelerate launch -m axolotl.cli.train your_config.yml

    [!TIP] You can also reference a config file that is hosted on a public URL, for example accelerate launch -m axolotl.cli.train https://yourdomain.com/your_config.yml

    Preprocess dataset

    You can optionally pre-tokenize dataset with the following before finetuning. This is recommended for large datasets.

    • Set dataset_prepared_path: to a local folder for saving and loading pre-tokenized dataset.
    • (Optional): Set push_dataset_to_hub: hf_user/repo to push it to Huggingface.
    • (Optional): Use --debug to see preprocessed examples.
    python -m axolotl.cli.preprocess your_config.yml

    Multi-GPU

    Below are the options available in axolotl for training with multiple GPUs. Note that DeepSpeed is the recommended multi-GPU option currently because FSDP may experience loss instability.

    DeepSpeed

    Deepspeed is an optimization suite for multi-gpu systems allowing you to train much larger models than you might typically be able to fit into your GPU's VRAM. More information about the various optimization types for deepspeed is available at https://huggingface.co/docs/accelerate/main/en/usage_guides/deepspeed#what-is-integrated

    We provide several default deepspeed JSON configurations for ZeRO stage 1, 2, and 3.

    deepspeed: deepspeed_configs/zero1.json
    accelerate launch -m axolotl.cli.train examples/llama-2/config.yml --deepspeed deepspeed_configs/zero1.json
    FSDP
    • llama FSDP
    fsdp: - full_shard - auto_wrap fsdp_config: fsdp_offload_params: true fsdp_state_dict_type: FULL_STATE_DICT fsdp_transformer_layer_cls_to_wrap: LlamaDecoderLayer
    FSDP + QLoRA

    Axolotl supports training with FSDP and QLoRA, see these docs for more information.

    Weights & Biases Logging

    Make sure your WANDB_API_KEY environment variable is set (recommended) or you login to wandb with wandb login.

    • wandb options
    wandb_mode: wandb_project: wandb_entity: wandb_watch: wandb_name: wandb_log_model:
    Special Tokens

    It is important to have special tokens like delimiters, end-of-sequence, beginning-of-sequence in your tokenizer's vocabulary. This will help you avoid tokenization issues and help your model train better. You can do this in axolotl like this:

    special_tokens: bos_token: "<s>" eos_token: "</s>" unk_token: "<unk>" tokens: # these are delimiters - "<|im_start|>" - "<|im_end|>"

    When you include these tokens in your axolotl config, axolotl adds these tokens to the tokenizer's vocabulary.

    Inference Playground

    Axolotl allows you to load your model in an interactive terminal playground for quick experimentation. The config file is the same config file used for training.

    Pass the appropriate flag to the inference command, depending upon what kind of model was trained:

    • Pretrained LORA:
      python -m axolotl.cli.inference examples/your_config.yml --lora_model_dir="./lora-output-dir"
    • Full weights finetune:
      python -m axolotl.cli.inference examples/your_config.yml --base_model="./completed-model"
    • Full weights finetune w/ a prompt from a text file:
      cat /tmp/prompt.txt | python -m axolotl.cli.inference examples/your_config.yml \ --base_model="./completed-model" --prompter=None --load_in_8bit=True

    -- With gradio hosting

    python -m axolotl.cli.inference examples/your_config.yml --gradio

    Please use --sample_packing False if you have it on and receive the error similar to below:

    RuntimeError: stack expects each tensor to be equal size, but got [1, 32, 1, 128] at entry 0 and [1, 32, 8, 128] at entry 1

    Merge LORA to base

    The following command will merge your LORA adapater with your base model. You can optionally pass the argument --lora_model_dir to specify the directory where your LORA adapter was saved, otherwhise, this will be inferred from output_dir in your axolotl config file. The merged model is saved in the sub-directory {lora_model_dir}/merged.

    python3 -m axolotl.cli.merge_lora your_config.yml --lora_model_dir="./completed-model"

    You may need to use the gpu_memory_limit and/or lora_on_cpu config options to avoid running out of memory. If you still run out of CUDA memory, you can try to merge in system RAM with

    CUDA_VISIBLE_DEVICES="" python3 -m axolotl.cli.merge_lora ...

    although this will be very slow, and using the config options above are recommended instead.

    [openaccess-ai-collective/axolotl] docs/config.qmd
    ---
    title: Config options
    description: A complete list of all configuration options.
    ---
    
    ```yaml
    # This is the huggingface model that contains *.pt, *.safetensors, or *.bin files
    # This can also be a relative path to a model on disk
    base_model: ./llama-7b-hf
    # You can specify an ignore pattern if the model repo contains more than 1 model type (*.pt, etc)
    base_model_ignore_patterns:
    # If the base_model repo on hf hub doesn't include configuration .json files,
    # You can set that here, or leave this empty to default to base_model
    base_model_config: ./llama-7b-hf
    # You can specify to choose a specific model revision from huggingface hub
    revision_of_model:
    # Optional tokenizer configuration path in case you want to use a different tokenizer
    # than the one defined in the base model
    tokenizer_config:
    # If you want to specify the type of model to load, AutoModelForCausalLM is a good choice too
    model_type: AutoModelForCausalLM
    # Corresponding tokenizer for the model AutoTokenizer is a good choice
    tokenizer_type: AutoTokenizer
    # Trust remote code for untrusted source
    trust_remote_code:
    # use_fast option for tokenizer loading from_pretrained, default to True
    tokenizer_use_fast:
    # Whether to use the legacy tokenizer setting, defaults to True
    tokenizer_legacy:
    # Resize the model embeddings when new tokens are added to multiples of 32
    # This is reported to improve training speed on some models
    resize_token_embeddings_to_32x:
    
    # (Internal use only)
    # Used to identify which the model is based on
    is_falcon_derived_model:
    is_llama_derived_model:
    is_qwen_derived_model:
    # Please note that if you set this to true, `padding_side` will be set to "left" by default
    is_mistral_derived_model:
    
    # optional overrides to the base model configuration
    overrides_of_model_config:
      # RoPE Scaling https://github.com/huggingface/transformers/pull/24653
      rope_scaling:
        type: # linear | dynamic
        factor: # float
    
    # optional overrides to the bnb 4bit quantization configuration
    # https://huggingface.co/docs/transformers/main/main_classes/quantization#transformers.BitsAndBytesConfig
    bnb_config_kwargs:
      # These are default values
      llm_int8_has_fp16_weight: false
      bnb_4bit_quant_type: nf4
      bnb_4bit_use_double_quant: true
    
    
    # Whether you are training a 4-bit GPTQ quantized model
    gptq: true
    
    # This will attempt to quantize the model down to 8 bits and use adam 8 bit optimizer
    load_in_8bit: true
    # Use bitsandbytes 4 bit
    load_in_4bit:
    
    # Use CUDA bf16
    bf16: true # bool or 'full' for `bf16_full_eval`. require >=ampere
    # Use CUDA fp16
    fp16: true
    # Use CUDA tf32
    tf32: true # require >=ampere
    
    # No AMP (automatic mixed precision)
    bfloat16: true # require >=ampere
    float16: true
    
    # Limit the memory for all available GPUs to this amount (if an integer, expressed in gigabytes); default: unset
    gpu_memory_limit: 20GiB
    # Do the LoRA/PEFT loading on CPU -- this is required if the base model is so large it takes up most or all of the available GPU VRAM, e.g. during a model and LoRA merge
    lora_on_cpu: true
    
    # A list of one or more datasets to finetune the model with
    datasets:
      # HuggingFace dataset repo | s3://,gs:// path | "json" for local dataset, make sure to fill data_files
      - path: vicgalle/alpaca-gpt4
      # The type of prompt to use for training. [alpaca, sharegpt, gpteacher, oasst, reflection]
        type: alpaca # format | format:<prompt_style> (chat/instruct) | <prompt_strategies>.load_<load_fn>
        ds_type: # Optional[str] (json|arrow|parquet|text|csv) defines the datatype when path is a file
        data_files: # Optional[str] path to source data files
        shards: # Optional[int] number of shards to split data into
        name: # Optional[str] name of dataset configuration to load
        train_on_split: train # Optional[str] name of dataset split to load from
    
        # Optional[str] fastchat conversation type, only used with type: sharegpt
        conversation: # Options (see Conversation 'name'): https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py
        field_human: # Optional[str]. Human key to use for conversation.
        field_model: # Optional[str]. Assistant key to use for conversation.
        # Add additional keys from your dataset as input or output roles
        roles:
          input: # Optional[List[str]]. These will be masked based on train_on_input
          output: # Optional[List[str]].
    
      # Custom user instruction prompt
      - path: repo
        type:
          # The below are defaults. only set what's needed if you use a different column name.
          system_prompt: ""
          system_format: "{system}"
          field_system: system
          field_instruction: instruction
          field_input: input
          field_output: output
    
          # Customizable to be single line or multi-line
          # Use {instruction}/{input} as key to be replaced
          # 'format' can include {input}
          format: |-
            User: {instruction} {input}
            Assistant:
          # 'no_input_format' cannot include {input}
          no_input_format: "{instruction} "
    
          # For `completion` datsets only, uses the provided field instead of `text` column
          field:
    
    # If false, the datasets will not be shuffled and will keep their original order in `datasets`.
    # The same applies to the `test_datasets` option and the `pretraining_dataset` option. Default is true.
    shuffle_merged_datasets: true
    
    # A list of one or more datasets to eval the model with.
    # You can use either test_datasets, or val_set_size, but not both.
    test_datasets:
      - path: /workspace/data/eval.jsonl
        ds_type: json
        # You need to specify a split. For "json" datasets the default split is called "train".
        split: train
        type: completion
        data_files:
          - /workspace/data/eval.jsonl
    
    # use RL training: 'dpo', 'ipo', 'kto_pair'
    rl:
    
    # Saves the desired chat template to the tokenizer_config.json for easier inferencing
    # Currently supports chatml and inst (mistral/mixtral)
    chat_template: chatml
    # Changes the default system message
    default_system_message: You are a helpful assistant. Please give a long and detailed answer. # Currently only supports chatml.
    # Axolotl attempts to save the dataset as an arrow after packing the data together so
    # subsequent training attempts load faster, relative path
    dataset_prepared_path: data/last_run_prepared
    # Push prepared dataset to hub
    push_dataset_to_hub: # repo path
    # The maximum number of processes to use while preprocessing your input dataset. This defaults to `os.cpu_count()`
    # if not set.
    dataset_processes: # defaults to os.cpu_count() if not set
    # Keep dataset in memory while preprocessing
    # Only needed if cached dataset is taking too much storage
    dataset_keep_in_memory:
    # push checkpoints to hub
    hub_model_id: # private repo path to push finetuned model
    # how to push checkpoints to hub
    # https://huggingface.co/docs/transformers/v4.31.0/en/main_classes/trainer#transformers.TrainingArguments.hub_strategy
    hub_strategy:
    # Whether to use hf `use_auth_token` for loading datasets. Useful for fetching private datasets
    # Required to be true when used in combination with `push_dataset_to_hub`
    hf_use_auth_token: # boolean
    # How much of the dataset to set aside as evaluation. 1 = 100%, 0.50 = 50%, etc. 0 for no eval.
    val_set_size: 0.04
    # Num shards for whole dataset
    dataset_shard_num:
    # Index of shard to use for whole dataset
    dataset_shard_idx:
    
    # The maximum length of an input to train with, this should typically be less than 2048
    # as most models have a token/context limit of 2048
    sequence_len: 2048
    # Pad inputs so each step uses constant sized buffers
    # This will reduce memory fragmentation and may prevent OOMs, by re-using memory more efficiently
    pad_to_sequence_len:
    # Use efficient multi-packing with block diagonal attention and per sequence position_ids. Recommend set to 'true'
    sample_packing:
    # Set to 'false' if getting errors during eval with sample_packing on.
    eval_sample_packing:
    # You can set these packing optimizations AFTER starting a training at least once.
    # The trainer will provide recommended values for these values.
    sample_packing_eff_est:
    total_num_tokens:
    # Increasing the following values helps with packing, but usually only slightly (<%1.)
    # The number of samples packed at a time.
    sample_packing_group_size: 100000
    # The number of samples which can be packed into one sequence. Increase if using a large sequence_len with many short samples.
    sample_packing_bin_size: 200
    
    # Passed through to transformers when loading the model when launched without accelerate
    # Use `sequential` when training w/ model parallelism to limit memory
    device_map:
    # Defines the max memory usage per gpu on the system. Passed through to transformers when loading the model.
    max_memory:
    
    # If you want to use 'lora' or 'qlora' or leave blank to train all parameters in original model
    adapter: lora
    # If you already have a lora model trained that you want to load, put that here.
    # This means after training, if you want to test the model, you should set this to the value of `output_dir`.
    # Note that if you merge an adapter to the base model, a new subdirectory `merged` will be created under the `output_dir`.
    lora_model_dir:
    
    # LoRA hyperparameters
    # For more details about the following options, see:
    # https://www.anyscale.com/blog/fine-tuning-llms-lora-or-full-parameter-an-in-depth-analysis-with-llama-2
    lora_r: 8
    lora_alpha: 16
    lora_dropout: 0.05
    lora_target_modules:
      - q_proj
      - v_proj
    #  - k_proj
    #  - o_proj
    #  - gate_proj
    #  - down_proj
    #  - up_proj
    lora_target_linear: # If true, will target all linear modules
    peft_layers_to_transform: # The layer indices to transform, otherwise, apply to all layers
    
    # If you added new tokens to the tokenizer, you may need to save some LoRA modules because they need to know the new tokens.
    # For LLaMA and Mistral, you need to save `embed_tokens` and `lm_head`. It may vary for other models.
    # `embed_tokens` converts tokens to embeddings, and `lm_head` converts embeddings to token probabilities.
    # https://github.com/huggingface/peft/issues/334#issuecomment-1561727994
    lora_modules_to_save:
    #  - embed_tokens
    #  - lm_head
    
    lora_fan_in_fan_out: false
    
    # LoRA+ hyperparameters
    # For more details about the following options, see:
    # https://arxiv.org/abs/2402.12354  and `src/axolotl/core/train_builder.py`
    loraplus_lr_ratio: # loraplus learning rate ratio lr_B / lr_A. Recommended value is 2^4.
    loraplus_lr_embedding: #  loraplus learning rate for lora embedding layers. Default value is 1e-6.
    
    peft:
      # Configuration options for loftq initialization for LoRA
      # https://huggingface.co/docs/peft/developer_guides/quantization#loftq-initialization
      loftq_config:
        loftq_bits:  # typically 4 bits
    
    # ReLoRA configuration
    # Must use either 'lora' or 'qlora' adapter, and does not support fsdp or deepspeed
    relora_steps: # Number of steps per ReLoRA restart
    relora_warmup_steps: # Number of per-restart warmup steps
    relora_anneal_steps: # Number of anneal steps for each relora cycle
    relora_prune_ratio: # threshold for optimizer magnitude when pruning
    relora_cpu_offload: # True to perform lora weight merges on cpu during restarts, for modest gpu memory savings
    
    # wandb configuration if you're using it
    # Make sure your `WANDB_API_KEY` environment variable is set (recommended) or you login to wandb with `wandb login`.
    wandb_mode: # "offline" to save run metadata locally and not sync to the server, "disabled" to turn off wandb
    wandb_project: # Your wandb project name
    wandb_entity: # A wandb Team name if using a Team
    wandb_watch:
    wandb_name: # Set the name of your wandb run
    wandb_run_id: # Set the ID of your wandb run
    wandb_log_model: # "checkpoint" to log model to wandb Artifacts every `save_steps` or "end" to log only at the end of training
    
    # mlflow configuration if you're using it
    mlflow_tracking_uri: # URI to mlflow
    mlflow_experiment_name: # Your experiment name
    hf_mlflow_log_artifacts:  # set to true to copy each saved checkpoint on each save to mlflow artifact registry
    
    # Where to save the full-finetuned model to
    output_dir: ./completed-model
    
    # Whether to use torch.compile and which backend to use
    torch_compile:  # bool
    torch_compile_backend:  # Optional[str]
    
    # Training hyperparameters
    
    # If greater than 1, backpropagation will be skipped and the gradients will be accumulated for the given number of steps.
    gradient_accumulation_steps: 1
    # The number of samples to include in each batch. This is the number of samples sent to each GPU.
    # Batch size per gpu = micro_batch_size * gradient_accumulation_steps
    micro_batch_size: 2
    eval_batch_size:
    num_epochs: 4
    warmup_steps: 100  # cannot use with warmup_ratio
    warmup_ratio: 0.05  # cannot use with warmup_steps
    learning_rate: 0.00003
    lr_quadratic_warmup:
    logging_steps:
    eval_steps: # Leave empty to eval at each epoch, integers for every N steps. decimal for fraction of total steps
    evals_per_epoch: # number of times per epoch to run evals, mutually exclusive with eval_steps
    save_strategy: # Set to `"no"` to skip checkpoint saves
    save_steps: # Leave empty to save at each epoch
    saves_per_epoch: # number of times per epoch to save a checkpoint, mutually exclusive with save_steps
    save_total_limit: # Checkpoints saved at a time
    # Maximum number of iterations to train for. It precedes num_epochs which means that
    # if both are set, num_epochs will not be guaranteed.
    # e.g., when 1 epoch is 1000 steps => `num_epochs: 2` and `max_steps: 100` will train for 100 steps
    max_steps:
    
    eval_table_size: # Approximate number of predictions sent to wandb depending on batch size. Enabled above 0. Default is 0
    eval_max_new_tokens: # Total number of tokens generated for predictions sent to wandb. Default is 128
    eval_causal_lm_metrics: # HF evaluate metrics used during evaluation. Default is ["sacrebleu", "comet", "ter", chrf]
    
    loss_watchdog_threshold: # High loss value, indicating the learning has broken down (a good estimate is ~2 times the loss at the start of training)
    loss_watchdog_patience: # Number of high-loss steps in a row before the trainer aborts (default: 3)
    
    # Save model as safetensors (require safetensors package)
    save_safetensors:
    
    # Whether to mask out or include the human's prompt from the training labels
    train_on_inputs: false
    # Group similarly sized data to minimize padding.
    # May be slower to start, as it must download and sort the entire dataset.
    # Note that training loss may have an oscillating pattern with this enabled.
    group_by_length: false
    
    # Whether to use gradient checkpointing https://huggingface.co/docs/transformers/v4.18.0/en/performance#gradient-checkpointing
    gradient_checkpointing: false
    # additional kwargs to pass to the trainer for gradient checkpointing
    # gradient_checkpointing_kwargs:
    #   use_reentrant: true
    
    # Stop training after this many evaluation losses have increased in a row
    # https://huggingface.co/transformers/v4.2.2/_modules/transformers/trainer_callback.html#EarlyStoppingCallback
    early_stopping_patience: 3
    
    # Specify a scheduler and kwargs to use with the optimizer
    lr_scheduler: # 'one_cycle' | 'log_sweep' | empty for cosine
    lr_scheduler_kwargs:
    cosine_min_lr_ratio: # decay lr to some percentage of the peak lr, e.g. cosine_min_lr_ratio=0.1 for 10% of peak lr
    cosine_constant_lr_ratio: # freeze lr at some percentage of the step, e.g. cosine_constant_lr_ratio=0.8 means start cosine_min_lr at 80% of training step (https://arxiv.org/pdf/2308.04014.pdf)
    
    # For one_cycle optim
    lr_div_factor: # Learning rate div factor
    
    # Specify optimizer
    # Valid values are driven by the Transformers OptimizerNames class, see:
    # https://github.com/huggingface/transformers/blob/95b374952dc27d8511541d6f5a4e22c9ec11fb24/src/transformers/training_args.py#L134
    #
    # Note that not all optimizers may be available in your environment, ex: 'adamw_anyprecision' is part of
    # torchdistx, 'adamw_bnb_8bit' is part of bnb.optim.Adam8bit, etc. When in doubt, it is recommended to start with the optimizer used
    # in the examples/ for your model and fine-tuning use case.
    #
    # Valid values for 'optimizer' include:
    # - adamw_hf
    # - adamw_torch
    # - adamw_torch_fused
    # - adamw_torch_xla
    # - adamw_apex_fused
    # - adafactor
    # - adamw_anyprecision
    # - sgd
    # - adagrad
    # - adamw_bnb_8bit
    # - lion_8bit
    # - lion_32bit
    # - paged_adamw_32bit
    # - paged_adamw_8bit
    # - paged_lion_32bit
    # - paged_lion_8bit
    # - galore_adamw
    # - galore_adamw_8bit
    # - galore_adafactor
    # - galore_adamw_layerwise
    # - galore_adamw_8bit_layerwise
    # - galore_adafactor_layerwise
    optimizer:
    # Dictionary of arguments to pass to the optimizer
    optim_args:
    # For Galore Optimizers the following optim_args are available
    # rank:  # type: int
    # update_proj_gap  # type: int
    # scale  # type: float
    # proj_type:  # type: str, default = std
    
    # The target modules to optimize, i.e. the module names that you would like to train, right now this is used only for GaLore algorithm
    
OpenAccess-AI-Collective/axolotl
huggingface/transformers
huggingface/peft
huggingface/accelerate