> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fine-tuning a large language model by using a Serverless AI job and Axolotl

You can use Serverless AI jobs to work with AI models and perform such operations as fine-tuning, scientific simulations, data processing or batch inference.

The example below demonstrates how to fine-tune the [Qwen/Qwen2.5-0.5B](https://huggingface.co/Qwen/Qwen2.5-0.5B) large language model (LLM) with the support of the Low-Rank Adaptation (LoRA). This example also includes [Axolotl](https://axolotl.ai), an open-source tool for fine-tuning. Axolotl provides a [public container image](https://hub.docker.com/r/axolotlai/axolotl), which you deploy in a job and, as a result, run fine-tuning.

For a quick walkthrough of the web console workflow, watch the video below. If you prefer other interfaces or written instructions, follow the steps further down.

<Frame caption="Visit [Nebius Academy](https://academy.nebius.com/trainer/nebius-ai-cloud-onboarding/lesson/b532ba82-1b87-4d8c-ae82-f99afa32d04d) for video tutorials to help you get started with Nebius AI Cloud.">
  <iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/ZjD489E0lls" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
</Frame>

## Costs

Nebius AI Cloud charges you for the following billing items:

* [Compute virtual machines](/compute/resources/pricing#virtual-machines-gpus-vcpus-ram) (VMs)
* [Boot disks](/compute/resources/pricing#disks) attached to the VMs
* Used space in Standard storage in an [Object Storage bucket](/object-storage/resources/pricing#storing-data)

## Prerequisites

<Tabs group="interfaces">
  <Tab title="Web console">
    Make sure you are in a [group](/iam/authorization/groups/index) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
  </Tab>

  <Tab title="CLI">
    1. Make sure you are in a [group](/iam/authorization/groups/index) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
    2. Install and configure the Nebius AI Cloud CLI and the AWS CLI. Here are the instructions, depending on what tools you have already installed:

    * [How to install both CLIs](/object-storage/quickstart#prepare-your-environment)
    * [How to install the Nebius AI Cloud CLI only](/cli/install)
    * How to [install](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions) and [configure](/object-storage/interfaces/aws-cli#configuring-aws-cli) the AWS CLI only
  </Tab>
</Tabs>

## Steps

### Prepare an Object Storage bucket

To store job results, mount an [Object Storage bucket](/object-storage/overview#buckets) to your job. Serverless AI deletes the job after its completion. Thus, the bucket preserves the job data: checkpoints and LoRA adapter weights of a fine-tuned model.

For visual guidance on creating a bucket and uploading objects in the web console, watch the video below. If you prefer other interfaces or written instructions, follow the steps further down.

<Frame caption="Visit [Nebius Academy](https://academy.nebius.com/trainer/nebius-ai-cloud-onboarding/lesson/b532ba82-1b87-4d8c-ae82-f99afa32d04d) for video tutorials to help you get started with Nebius AI Cloud.">
  <iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/Cx7BlL6PdKk" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
</Frame>

1. Create a bucket:

   <Tabs group="interfaces">
     <Tab title="Web console">
       1. In the [web console](https://console.nebius.com), go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/rOlLZ_MFvrheaI-h/_assets/sidebar/storage.svg?fit=max&auto=format&n=rOlLZ_MFvrheaI-h&q=85&s=f060b15cbd82c08f84599faeeeb07ece" width="16" height="16" data-path="_assets/sidebar/storage.svg" /> **Storage** → **Object Storage**.

       2. Click <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/plus.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=7c9efc69d65fc58db0eb73702fd81aa1" width="16" height="16" data-path="_assets/plus.svg" /> **Create bucket**.

       3. Specify the `fine-tuning-axolotl` name for the bucket.

       4. In the **Maximum size** field, select **Unlimited**.

          Leave the other settings at their default values.

       5. Click **Create bucket**.
     </Tab>

     <Tab title="CLI">
       ```bash theme={null}
       nebius storage bucket create --name fine-tuning-axolotl
       ```
     </Tab>
   </Tabs>

2. Save the `config.yaml` file specified below. It is required for Axolotl to run fine-tuning.

   ```yaml theme={null}
   base_model: Qwen/Qwen2.5-0.5B

   load_in_4bit: true
   adapter: qlora

   datasets:
     - path: Salesforce/wikitext
       name: wikitext-2-raw-v1
       split: "train[:2000]"
       type: completion
       field: text

   sequence_len: 128
   micro_batch_size: 1
   gradient_accumulation_steps: 1

   learning_rate: 2e-4
   max_steps: 30
   val_set_size: 0
   logging_steps: 5

   output_dir: /workspace/output

   lora_r: 8
   lora_alpha: 16
   lora_dropout: 0.05
   lora_target_modules:
     - q_proj
     - k_proj
     - v_proj
     - o_proj
     - gate_proj
     - up_proj
     - down_proj
   ```

3. Upload this configuration file to the bucket:

   <Tabs group="interfaces">
     <Tab title="Web console">
       1. In the web console, go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/rOlLZ_MFvrheaI-h/_assets/sidebar/storage.svg?fit=max&auto=format&n=rOlLZ_MFvrheaI-h&q=85&s=f060b15cbd82c08f84599faeeeb07ece" width="16" height="16" data-path="_assets/sidebar/storage.svg" /> **Storage** → **Object Storage**.
       2. Open the page of the `fine-tuning-axolotl` bucket.
       3. Click **Add** → **Object**.
       4. Upload the `config.yaml` file.
     </Tab>

     <Tab title="CLI">
       ```bash theme={null}
       aws s3 cp config.yaml s3://fine-tuning-axolotl/config.yaml
       ```

       The file is stored in the `fine-tuning-axolotl` bucket as the `config.yaml` object.

       Run this command in the directory where `config.yaml` is stored. Alternatively, specify an actual path to the file after `cp`.
     </Tab>
   </Tabs>

### Run a fine-tuning job

Create a job that performs the following actions:

1. Runs an Axolotl container.
2. Mounts the bucket with the prepared configuration file in the read-write mode.
3. Executes fine-tuning.
4. Saves the fine-tuning results to the bucket.

To create and run such a job:

<Tabs group="interfaces">
  <Tab title="Web console">
    1. In the web console, go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/rOlLZ_MFvrheaI-h/_assets/sidebar/serverless-ai.svg?fit=max&auto=format&n=rOlLZ_MFvrheaI-h&q=85&s=4c90b50c6c33e6bff000b87b8e37765a" width="16" height="16" data-path="_assets/sidebar/serverless-ai.svg" /> **Serverless AI** → **Jobs**.

    2. Click <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/plus.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=7c9efc69d65fc58db0eb73702fd81aa1" width="16" height="16" data-path="_assets/plus.svg" /> **Create job**.

    3. On the page that opens, specify the following job settings:

       * **Name**: `fine-tuning-axolotl-qwen-lora`.

       * **Image path**: `docker.io/axolotlai/axolotl:main-20260309-py3.11-cu128-2.9.1`.

       * **Entrypoint command**:

         ```bash theme={null}
         bash -c "RUN_ID=run-$(date +%Y%m%d-%H%M%S); axolotl train /workspace/data/config.yaml && mkdir -p /workspace/data/output/$RUN_ID && cp -r /workspace/output/. /workspace/data/output/$RUN_ID"
         ```

       * **Computing resources**: With GPU.

       * **Available platform**: NVIDIA® L40S PCIe with Intel Ice Lake.

       * **Preset**: 1 GPU — 8 CPUs — 32 GiB RAM.

       * **Container disk, Size GiB**: 450.

       * **Mount volumes**: Bucket.

       * **Mount path**: `/workspace/data`. After that, click <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/plus.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=7c9efc69d65fc58db0eb73702fd81aa1" width="16" height="16" data-path="_assets/plus.svg" /> **Attach bucket** and then select the `fine-tuning-axolotl` bucket.

    4. Click **Create**.
  </Tab>

  <Tab title="CLI">
    Run the following command:

    ```bash theme={null}
    nebius ai job create \
      --name "fine-tuning-axolotl-qwen-lora" \
      --subnet-id "<subnet_ID>" \
      --image docker.io/axolotlai/axolotl:main-20260309-py3.11-cu128-2.9.1 \
      --platform gpu-l40s-a \
      --preset 1gpu-8vcpu-32gb \
      --disk-size 450Gi \
      --volume "<bucket_ID>:/workspace/data" \
      --container-command bash \
      --args '-c "RUN_ID=run-$(date +%Y%m%d-%H%M%S); axolotl train /workspace/data/config.yaml && mkdir -p /workspace/data/output/$RUN_ID && cp -r /workspace/output/. /workspace/data/output/$RUN_ID"'
    ```

    The command contains the following parameters:

    * `--name`: Job name.

    * `--subnet-id`: [Subnet ID](/vpc/networking/resources#how-to-get-a-subnet-id).

    * `--image`: Container image to run. In the given example, the [public Axolotl container image](https://hub.docker.com/r/axolotlai/axolotl) is used.

    * `--platform`: Virtual machine (VM) platform for the job. As Serverless AI jobs are based on [container VMs](/compute/virtual-machines/containers) in Compute, every job uses [Compute platforms and presets](/compute/virtual-machines/types).

    * `--preset`: Number of GPUs, vCPUs and RAM allocated to the container. The preset must match the selected platform.

    * `--disk-size`: Size of the job container disk.

    * `--volume`: Volume to mount to the job container. Specify the ID of the `fine-tuning-axolotl` bucket created earlier. The bucket is used to store the job results and checkpoints.

      To get the bucket ID, run `nebius storage bucket get-by-name --name fine-tuning-axolotl`.

    * `--container-command`: Entrypoint command for the job container.

    * `--args`: Arguments for `docker run` to pass to the entrypoint command.
  </Tab>
</Tabs>

The job takes several minutes to complete.

### Check the job results

1. View information about the job:

   <Tabs group="interfaces">
     <Tab title="Web console">
       In the web console, go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/rOlLZ_MFvrheaI-h/_assets/sidebar/serverless-ai.svg?fit=max&auto=format&n=rOlLZ_MFvrheaI-h&q=85&s=4c90b50c6c33e6bff000b87b8e37765a" width="16" height="16" data-path="_assets/sidebar/serverless-ai.svg" /> **Serverless AI** → **Jobs** and then open the page of the `fine-tuning-axolotl-qwen-lora` job. It contains information about the job state and configuration.
     </Tab>

     <Tab title="CLI">
       ```bash theme={null}
       nebius ai job get <job_ID>
       ```

       The command output shows the job state and configuration.

       To get the job ID, run `nebius ai job get-by-name --name fine-tuning-axolotl-qwen-lora`.
     </Tab>
   </Tabs>

2. Download LoRA adapter weights of the fine-tuning job. They are stored as files in the `output` directory, in the `fine-tuning-axolotl` bucket. To check these files, open the page of the `fine-tuning-axolotl` bucket in the [web console](https://console.nebius.com/).

   <Tabs group="interfaces">
     <Tab title="Web console">
       To download a file, in its line, click <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/button-vellipsis.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=e80b8e57c43bfd117679262e6a1334ad" width="12" height="24" data-path="_assets/button-vellipsis.svg" /> → **Download**.
     </Tab>

     <Tab title="CLI">
       Command example for downloading a file:

       ```bash theme={null}
       aws s3 cp s3://fine-tuning-axolotl/output/run-20260309-160510/checkpoint-30/adapter_config.json download/output/run-20260309-160510/checkpoint-30/adapter_config.json
       ```

       In this example, the `s3://...` path points to the file in the bucket, and the `download/...` path points to a local `download` directory.
     </Tab>
   </Tabs>

## How to delete the created resources

Used space in the created bucket is chargeable. If you don't need it, [delete the bucket](/object-storage/buckets/manage#how-to-delete-buckets), so Nebius AI Cloud doesn't charge for it.

## See also

* [Axolotl quickstart](https://docs.axolotl.ai/docs/getting-started.html)
* [Example: Fine-Tune Qwen3 14B with Axolotl](https://docs.axolotl.ai/examples/colab-notebooks/colab-axolotl-example.html)
* [Axolotl GitHub repository](https://github.com/axolotl-ai-cloud/axolotl)
