# Phi 2.0 - Training

### <mark style="color:green;">Training Phi 2.0</mark>

To execute the main training script Axolotl provides this command to begin training Phi 2.0

```bash
accelerate launch -m axolotl.cli.train examples/phi/phi2-ft.yml
```

If you have not already done so, you will be asked to enter your Weights and Biases API Key.&#x20;

&#x20;Enter the key at the command line prompt:

```yaml
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

### <mark style="color:blue;">An analysis of the axolotl.clt.train module</mark>

<details>

<summary><mark style="color:green;">Analysis of train.py script</mark></summary>

The <mark style="color:yellow;">**`train.py`**</mark> script in the Axolotl platform is a Command Line Interface (CLI) tool designed for training machine learning models.&#x20;

This script is structured to provide a user-friendly interface for configuring and executing model training. Here's a detailed analysis:

#### <mark style="color:blue;">Script Structure and Functionality</mark>

<mark style="color:green;">**Imports and Logger Setup**</mark>

* Essential modules like <mark style="color:yellow;">**`logging`**</mark><mark style="color:yellow;">**,**</mark><mark style="color:yellow;">**&#x20;**</mark><mark style="color:yellow;">**`pathlib.Path`**</mark><mark style="color:yellow;">**,**</mark><mark style="color:yellow;">**&#x20;**</mark><mark style="color:yellow;">**`fire`**</mark>, and <mark style="color:yellow;">**`transformers`**</mark> are imported.
* The script sets up a logger <mark style="color:yellow;">**`LOG`**</mark> using the <mark style="color:yellow;">**`logging`**</mark> module for logging various events and statuses during the script's execution.

<mark style="color:green;">**do\_cli Function**</mark>

* <mark style="color:blue;">**Function Definition**</mark><mark style="color:blue;">:</mark> The <mark style="color:yellow;">**`do_cli`**</mark> function is the main entry point of the script. It accepts a <mark style="color:yellow;">**`config`**</mark> argument (with a default value pointing to an "examples" directory) and <mark style="color:yellow;">**`**kwargs`**</mark> for additional arguments.
* <mark style="color:blue;">**ASCII Art Display**</mark><mark style="color:blue;">:</mark> <mark style="color:yellow;">**`print_axolotl_text_art()`**</mark> is called to display ASCII art, likely for aesthetic purposes.
* <mark style="color:blue;">**Configuration Loading**</mark><mark style="color:blue;">:</mark> <mark style="color:yellow;">**`load_cfg`**</mark> loads configuration details from the provided `config` path. These configurations are essential for setting up model training parameters.
* <mark style="color:blue;">**Accelerator and User Token Checks**</mark><mark style="color:blue;">:</mark> The script verifies the default configuration for the accelerator (such as a GPU) and checks the user token. These checks are crucial for ensuring that the hardware is correctly set up and the user is authenticated.
* <mark style="color:blue;">**CLI Arguments Parsing**</mark><mark style="color:blue;">:</mark> It uses <mark style="color:yellow;">**`transformers.HfArgumentParser`**</mark> to parse additional CLI arguments into data classes (<mark style="color:yellow;">**`TrainerCliArgs`**</mark>). This step allows for dynamic customization of training parameters via the command line.
* <mark style="color:blue;">**Dataset Loading**</mark><mark style="color:blue;">:</mark> <mark style="color:yellow;">**`load_datasets`**</mark> is called with the parsed configuration and CLI arguments. This function is responsible for loading the dataset as per the configuration, which is a critical step in the training process.
* <mark style="color:blue;">**Model Training**</mark><mark style="color:blue;">:</mark> The <mark style="color:yellow;">**`train`**</mark> function is invoked with the loaded configuration, CLI arguments, and dataset metadata. This function likely encompasses the core logic for model training.

<mark style="color:green;">**Main Block**</mark>

* The script checks if it's being run as the main program <mark style="color:yellow;">**(**</mark><mark style="color:yellow;">**`__name__ == "__main__"`**</mark><mark style="color:yellow;">**)**</mark> and not as a module in another script. If it's the main program, it uses <mark style="color:yellow;">**`fire.Fire(do_cli)`**</mark> to execute the <mark style="color:yellow;">**`do_cli`**</mark> function, enabling the script to be interacted with from the command line.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://axolotl.continuumlabs.pro/phi-2.0/phi-2.0-training.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
