---
title: "AI Notebooks - Tutorial - Fine-tuning LLaMA 2"
description: "Learn how to fine-tune LLaMA 2 models using OVHcloud AI Notebooks and a single GPU. This allows you to retrain the model to suit your needs using your own datas"
url: https://docs.us.ovhcloud.com/en/public-cloud/ai-machine-learning/ai-notebooks-tuto-fine-tune-llama-v2
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# AI Notebooks - Tutorial - Fine-tuning LLaMA 2

**Learn how to fine-tune LLaMA 2 models using [OVHcloud AI Notebooks](https://us.ovhcloud.com/public-cloud/ai-notebooks/) and a single GPU. This allows you to retrain the model to suit your needs using your own dataset.** We will use [QLoRA](https://arxiv.org/abs/2305.14314), a highly efficient LLM fine-tuning technique.

On July 18, 2023, [Meta](https://about.meta.com/) released [LLaMA 2](https://ai.meta.com/llama/), the latest version of their open-source Large Language Model (LLM).

Trained between January 2023 and July 2023 on 2 trillion tokens, LLaMA 2 outperforms other LLMs on many benchmarks, including reasoning, coding, proficiency, and knowledge tests. This release comes in different flavors, with parameter sizes of 7B, 13B, and a mind-blowing 70B. Models are intended for free for both commercial and research use in English.

 

## Requirements

- Access to the [OVHcloud Control Panel](https://manager.us.ovhcloud.com/)
- An AI Notebooks project created inside a [Public Cloud project](https://us.ovhcloud.com/public-cloud/) in your OVHcloud account
- A user for AI Notebooks

**Note:**

To access LLaMA 2 models, you will also need to follow the requirements indicated in the notebook.

 

## Instructions

You can launch the notebook from the [OVHcloud Control Panel](https://manager.us.ovhcloud.com/) or via the [ovhai CLI](https://docs.us.ovhcloud.com/en/public-cloud/ai-machine-learning/cli-run-notebook.md).

 

### Launching a Jupyter notebook with "Conda" via UI (Control Panel)

To launch your notebook from the [OVHcloud Control Panel](https://manager.us.ovhcloud.com/), refer to the following steps.

 

#### Code editor

Choose the `Jupyterlab` code editor.

 

#### Framework

In this tutorial, the `conda` framework is used.

 

#### Resources

Using at least one **GPU is mandatory** since fine-tuning LLMs is an intensive task.

 

### Launching a Jupyter notebook with "conda" via CLI

_If you have not used our CLI yet, follow [this guide](https://docs.us.ovhcloud.com/en/public-cloud/ai-machine-learning/cli-install-client.md) to install it._

If you want to launch your notebook with the OVHcloud AI CLI, choose the `jupyterlab` editor and the `conda` framework.

To access the different versions of `conda` available, run the following command:

```console
ovhai capabilities framework get conda -o yaml
```

**Note:**

If you do not specify a version, your notebook starts with the default version of `conda`.

You will also need to choose the number of GPUs to use in your notebook using `<nb-gpus>`.

To launch your notebook, run the following command:

```console
ovhai notebook run conda jupyterlab \
        --name <notebook-name> \
        --framework-version <conda-version> \
        --gpu <nb-gpus>
```

You can then reach your notebook’s URL once the notebook is running.

 

### Accessing the notebooks

Once our [AI examples repository](https://github.com/ovh/ai-training-examples/) has been cloned in your environment, find the fine-tuning notebook tutorial by following this path: `ai-training-examples` > `notebooks` > `natural-language-processing` > `llm/miniconda/llama2-fine-tuning` > `llama_2_finetuning.ipynb`.

A direct link to the notebook can be found [here](https://github.com/ovh/ai-training-examples/blob/main/notebooks/natural-language-processing/llm/miniconda/llama2-fine-tuning/llama_2_finetuning.ipynb).

 

## Go further

Don't forget to keep an eye on our upcoming tutorials, where we will be deploying our fine-tuned LLaMA model on [AI Deploy](https://us.ovhcloud.com/public-cloud/ai-deploy/) for inference!

Browse all the [AI & Machine Learning guides](https://docs.us.ovhcloud.com/en/public-cloud/ai-machine-learning/landing-page-ai-machine-learning.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [AI & Machine Learning](https://us.ovhcloud.com/public-cloud/ai-machine-learning/) on the OVHcloud US website.

If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](https://us.ovhcloud.com/professional-services/) to get a quote and ask our Professional Services experts for a custom analysis of your project.
