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

# Fine-Tuning Models on Oxen.ai

> Oxen.ai allows you to fine-tune text, image, and video models with a few clicks.

Simply [upload your data](/getting-started/datasets), and we will provision GPU infrastructure and run the fine-tune. When it's done, Oxen.ai will save the fine-tuned model weights directly to your repository, and we spin down the GPU for you. No worrying about run away costs or having to manage your own infrastructure.

Once the fine-tuning process is complete, you can deploy your model to a dedicated endpoint and use the [inference endpoints](/getting-started/inference) to integrate it into your application.

<img alt="Fine-Tuning Ox" className="rounded-xl" src="https://mintcdn.com/oxenai/T4_0EQB1ENVXiGMM/images/fine_tuning/fine-tune-ox.jpg?fit=max&auto=format&n=T4_0EQB1ENVXiGMM&q=85&s=c9f8a79a314a6288026b39d76e340d1c" width="3600" height="2028" data-path="images/fine_tuning/fine-tune-ox.jpg" />

Oxen.ai automatically [versions](/getting-started/versioning) and manages the raw model weights and datasets, so that you can always track the data that was used to train the model, or download the model to run locally.

## Why Fine-Tune?

Fine-tuning is a great tool to reach for when basic prompting and context engineering fall short. You may need to fine-tune when:

* **Quality** is critical and the model isn't consistently producing correct outputs.
* **Proprietary Data** gives you a unique advantage that generic models can't capture.
* **Latency**  is a deal breaker and you need real-time responses.
* **Throughput** limitations are bottlenecking your application's scalability.
* **Ownership** of the model is important and you want to control your own destiny.
* **Cost** if a foundation model is too expensive for your use case or you want to deploy a smaller model to the edge.

With Oxen.ai, we make it easy to automate the fine-tuning process of LLMs on your own data.

## Modalities

Oxen.ai supports many data types and tasks for fine-tuning.

<CardGroup cols={3}>
  <Card title="Text Generation" icon="file-pen" href="/examples/fine-tuning/text_generation">
    Fine-tune a model to take a user input as text and generate a single response as text.
  </Card>

  <Card title="Chat Completions" icon="message" href="/examples/fine-tuning/chat_completions">
    Fine-tune a model on chat messages to have a conversation with a user.
  </Card>

  <Card title="Image Generation" icon="palette" href="/examples/fine-tuning/image_generation">
    Fine-tune a model to go from text descriptions to images.
  </Card>

  <Card title="Image Editing" icon="paintbrush" href="/examples/fine-tuning/image_editing">
    Fine-tune a model to take a prompt and a reference image and generate a new image.
  </Card>

  <Card title="Video Generation" icon="video" href="/examples/fine-tuning/video_generation">
    Fine-tune a model to take in a prompt and generate a video.
  </Card>
</CardGroup>

## Start by Uploading a Dataset

To get started, you'll need to create a new repository on Oxen.ai. Once you've created a repository, you can upload your data. The dataset can be in any tabular format including `csv`, `jsonl`, or `parquet`.

<img alt="Fine-Tuning Dataset Upload" className="rounded-xl" src="https://mintcdn.com/oxenai/T4_0EQB1ENVXiGMM/images/fine_tuning/fine-tune-upload-file.png?fit=max&auto=format&n=T4_0EQB1ENVXiGMM&q=85&s=a16ad9326ccb4cb037c4f551c17b4d3d" width="2804" height="1562" data-path="images/fine_tuning/fine-tune-upload-file.png" />

Once you have your dataset uploaded, you can query, explore, and make sure that the data is high quality before kicking off the fine-tuning process. Your model will only be as good as the data you train it on.

<img src="https://mintcdn.com/oxenai/GvHCMKbbr_BpHEwk/images/fine_tuning/fine-tune-dataset.png?fit=max&auto=format&n=GvHCMKbbr_BpHEwk&q=85&s=75d3369875023b8cf44f387e13494568" alt="Fine-Tuning Dataset" width="1600" height="962" data-path="images/fine_tuning/fine-tune-dataset.png" />

When you feel confident that your dataset is ready, use the "Actions" button to select the model you want to fine-tune.

<img alt="Fine-Tuning Dataset" className="rounded-xl" src="https://mintcdn.com/oxenai/GvHCMKbbr_BpHEwk/images/fine_tuning/fine-tune-actions.png?fit=max&auto=format&n=GvHCMKbbr_BpHEwk&q=85&s=20f6f40b3c070acb3f86b3213a069c07" width="2656" height="1184" data-path="images/fine_tuning/fine-tune-actions.png" />

## Selecting a Model

This will take you to a form where you can select the model you want to fine-tune and the columns you want to use for the fine-tuning process. We support fine-tuning for [text generation](/examples/fine-tuning/text_generation), [image generation](/examples/fine-tuning/image_generation), [image editing](/examples/fine-tuning/image_editing), and [video generation](/examples/fine-tuning/video_generation) with a variety of models.

<img alt="Fine-Tuning Model Selection" className="rounded-xl" src="https://mintcdn.com/oxenai/T4_0EQB1ENVXiGMM/images/fine_tuning/fine-tune-model-selection.png?fit=max&auto=format&n=T4_0EQB1ENVXiGMM&q=85&s=8656b3e176e96a202ec6be8249bb6af9" width="2746" height="1076" data-path="images/fine_tuning/fine-tune-model-selection.png" />

<Info>
  If you want support for any specific models, data formats, training methods contact us at [hello@oxen.ai](mailto:hello@oxen.ai) and we are happy to help you get started. We are actively working on support for new models and distributed training.
</Info>

## Monitoring the Fine-Tune

Once you have started the fine-tuning process, you can monitor its progress. The dashboard will show you loss over time and token accuracy processed.

<img alt="Fine-Tuning Monitoring" className="rounded-xl" src="https://mintcdn.com/oxenai/GvHCMKbbr_BpHEwk/images/fine_tuning/fine-tune-loss.png?fit=max&auto=format&n=GvHCMKbbr_BpHEwk&q=85&s=26e6cda451537e564a657297b4db04ca" width="2146" height="636" data-path="images/fine_tuning/fine-tune-loss.png" />

If you are fine-tuning an [image](/examples/fine-tuning/image_generation) or [video](/examples/fine-tuning/video_generation) generation model, you can view the generated images or videos in the "Samples" tab to get a feel for the model's performance.

<img alt="Fine-Tuning Samples" className="rounded-xl" src="https://mintcdn.com/oxenai/T4_0EQB1ENVXiGMM/images/fine_tuning/fine-tune-samples.png?fit=max&auto=format&n=T4_0EQB1ENVXiGMM&q=85&s=6075fc9546d7f2749c94c6f35d2811f0" width="2754" height="1178" data-path="images/fine_tuning/fine-tune-samples.png" />

Click on the "Info" tab to see the fine-tuning configuration and all the hyper-parameters used. This will include a link to the [dataset version](/getting-started/versioning) you used and the raw model weights for downloading and running locally.

<img alt="Fine-Tuning Samples" className="rounded-xl" src="https://mintcdn.com/oxenai/GvHCMKbbr_BpHEwk/images/fine_tuning/fine-tune-info-tab.png?fit=max&auto=format&n=GvHCMKbbr_BpHEwk&q=85&s=1e76a98705f6aaef58cdcb33dc5f432d" width="2752" height="1318" data-path="images/fine_tuning/fine-tune-info-tab.png" />

## Deploying the Model

Once the model is fine-tuned, you can deploy it to a dedicated endpoint or in the playground.

This will give you a `/ai/chat/completions` api and a playground that you can use to test out the model.

Start by using the "playgroud" button.

<img alt="Fine-Tuning Configuration" className="rounded-xl" src="https://mintcdn.com/oxenai/D1rpfmXbqvsK8ph0/images/fine_tuning/fine-tune-deploy-model.png?fit=max&auto=format&n=D1rpfmXbqvsK8ph0&q=85&s=b59d83bcd8ced343d7703cf5ce99460d" width="2982" height="1524" data-path="images/fine_tuning/fine-tune-deploy-model.png" />

if the model is not loaded you'll see an "inactive" button on the top right of the playgroud.

<img alt="Fine-Tuning Configuration" className="rounded-xl" src="https://mintcdn.com/oxenai/D1rpfmXbqvsK8ph0/images/fine_tuning/fine-tune-deploy-model-inactive.png?fit=max&auto=format&n=D1rpfmXbqvsK8ph0&q=85&s=a563335e4901ccb4c9e8d4b3c8fd7563" width="2982" height="1524" data-path="images/fine_tuning/fine-tune-deploy-model-inactive.png" />

use the activate button to load the model.

<img alt="Fine-Tuning Configuration" className="rounded-xl" src="https://mintcdn.com/oxenai/D1rpfmXbqvsK8ph0/images/fine_tuning/fine-tune-deploy-model-active.png?fit=max&auto=format&n=D1rpfmXbqvsK8ph0&q=85&s=b3c8b6bd53bce7f066a5ecf4a7dafc0b" width="2982" height="1524" data-path="images/fine_tuning/fine-tune-deploy-model-active.png" />

To use the API Swap out the model name with the name of the model you want to use.

```bash theme={null}
curl https://hub.oxen.ai/api/ai/chat/completions -H "Content-Type: application/json" -d '{
    "model":"oxen:my-model-name",
    "messages": [{"role": "user", "content": "What is the best name for a friendly ox?"}],
}'
```

## Using the Model

Once the model is deployed, you can also chat with it using the Oxen.ai chat interface at the playgroud. Learn more about the [chat interface here](/getting-started/inference).

<img alt="Chatting with the Model" className="rounded-xl" src="https://mintcdn.com/oxenai/s_o9ZlhOEkYJf27_/images/chat/chat_window_powerful_coffee_chimpanzee.png?fit=max&auto=format&n=s_o9ZlhOEkYJf27_&q=85&s=da4770552d70fc735792f5e0acdf6620" width="2874" height="1406" data-path="images/chat/chat_window_powerful_coffee_chimpanzee.png" />

For image and video generation, you can use the [playground](https://oxen.ai/ai/models) to generate images and videos.

<img alt="Chatting with the Model" className="rounded-xl" src="https://mintcdn.com/oxenai/T4_0EQB1ENVXiGMM/images/fine_tuning/model-playground.png?fit=max&auto=format&n=T4_0EQB1ENVXiGMM&q=85&s=f8ce52e6962271cb0e9edc7f5158c0b6" width="3024" height="1616" data-path="images/fine_tuning/model-playground.png" />

## Downloading the Model

If you want access to the raw model weights, you can download them from the repository using the Oxen.ai [Python Library](/getting-started/python) or the [CLI](/getting-started/cli).

Follow the instructions for [installing oxen](/getting-started/install) if you haven't already.

<CodeGroup>
  ```bash CLI theme={null}
  oxen download my-username/my-repo models/ox-artistic-cyan-elephant/model.safetensors --revision models/ox-artistic-cyan-elephant
  ```

  ```python Python theme={null}
  from oxen import RemoteRepo

  repo = RemoteRepo("my-username/my-repo")

  repo.download("models/ox-artistic-cyan-elephant/model.safetensors", revision="models/ox-artistic-cyan-elephant")
  ```
</CodeGroup>

<img alt="Fine-Tuning Configuration" className="rounded-xl" src="https://mintcdn.com/oxenai/T4_0EQB1ENVXiGMM/images/fine_tuning/fine-tune-model-weights.png?fit=max&auto=format&n=T4_0EQB1ENVXiGMM&q=85&s=b9e508d20cfdd8425d93d142dc80b554" width="2056" height="1334" data-path="images/fine_tuning/fine-tune-model-weights.png" />

## Need Custom Infrastructure?

If you need custom or private deployments in your own VPC or want to train a larger model on distributed infrastructure, contact us at [hello@oxen.ai](mailto:hello@oxen.ai) and we can give you a custom deployment.
