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

# Bring your own model

> Fine-tune a Hugging Face model that isn't in the Together catalog.

Together's bring-your-own-model (BYOM) flow lets you fine-tune a model from a Hugging Face repository that isn't in the official catalog, by pairing a base model from Together (the training template) with your custom checkpoint from Hugging Face (the actual weights to tune).

## When to BYOM

Use the BYOM flow when:

* **You want to start from a community variant:** A specialized model on Hugging Face (medical, legal, code) sometimes makes a better starting point than a generic base.
* **You're continuing your own previous work:** Upload your last checkpoint to Hugging Face and resume training on Together.
* **A new model isn't in the catalog yet:** As long as it has a supported architecture under 100B parameters, you can fine-tune it.

## Requirements

Your model must meet these constraints:

* **Architecture:** CausalLM only (text generation).
* **Size:** Under 100 billion parameters.
* **Weights:** `.safetensors` format.
* **No custom code:** `trust_remote_code=True` is not allowed.
* **Access:** The Hugging Face repo is public, or you have an API token with read access.
* **Framework compatibility:** Transformers v5.10 or earlier.

You'll also need a Together base model whose architecture matches your custom checkpoint (Llama, Qwen, Mistral, Gemma, etc.) and whose `max_seq_length` is no larger than your checkpoint supports.

## Launch the job

Launch the job by pairing the base model (template) with `from_hf_model` (your checkpoint):

```bash CLI theme={null}
tg fine-tuning create \
  --training-file "<FILE_ID>" \
  --model "Qwen/Qwen3.5-9B" \
  --from-hf-model "Qwen/Qwen3.5-9B-Base" \
  --n-epochs 3 \
  --learning-rate 1e-5 \
  --suffix "custom-v1"
```

```python Python theme={null}
from together import Together

client = Together()

job = client.fine_tuning.create(
    model="Qwen/Qwen3.5-9B",  # base template
    from_hf_model="Qwen/Qwen3.5-9B-Base",  # your custom model
    training_file="<FILE_ID>",
    n_epochs=3,
    learning_rate=1e-5,
    suffix="custom-v1",
    # hf_api_token="hf_xxxxxxxxxxxx",  # for a private repo
    # hf_model_revision="abc123def456",  # to pin a specific commit
)
print(job.id)
```

```typescript TypeScript theme={null}
import Together from "together-ai";

const client = new Together();

const job = await client.fineTuning.create({
  model: "Qwen/Qwen3.5-9B",
  from_hf_model: "Qwen/Qwen3.5-9B-Base",
  training_file: "<FILE_ID>",
  n_epochs: 3,
  learning_rate: 1e-5,
  suffix: "custom-v1",
});
console.log(job.id);
```

| Parameter | Purpose |
| - | - |
| `model` | A base model from Together's catalog. Its config provides the training template and inference setup. |
| `from_hf_model` | The Hugging Face repo with your custom weights. |
| `hf_api_token` | Only needed for private repos. Omit for public ones. Passing a dummy value can cause a 400 error. |
| `hf_model_revision` | Optional. Pin to a specific commit hash instead of `main`. |

## Pick the base template

Match these three variables to pick the base template:

* **Architecture:** Must match (treat Code Llama as Llama, etc.).
* **Size:** As close to your custom checkpoint as the catalog allows. If every option is larger, pick the smallest.
* **Max sequence length:** The base's max must be at least as large as your checkpoint's, and ideally not much larger.

For example: `Qwen/Qwen3.5-9B-Base` has Qwen3.5 architecture and 9B parameters. The catalog has a direct match, `Qwen/Qwen3.5-9B`: the same architecture and size, with a max sequence length that covers the checkpoint's.

## Watch and deploy

BYOM jobs use the same lifecycle as catalog jobs:

* [Poll the job](https://docs.together.ai/docs/fine-tuning/monitoring.md#poll-until-the-job-is-done) with the SDK or CLI.
* Deploy the result on a [dedicated endpoint](https://docs.together.ai/docs/fine-tuning/deployment.md). Your fine-tuned model appears under **My Models** in the [dashboard](https://api.together.ai/models) once training completes.

The base model dictates whether the result can be hosted. If the base model isn't in the [supported models](https://docs.together.ai/docs/dedicated-endpoints/models.md) list for dedicated model inference, the fine-tune can't be deployed as a dedicated endpoint. Pick a supported base before training.

## Troubleshooting

* **Training fails with a CUDA out-of-memory error:** Reduce `batch_size` or use a smaller base template.
* **Training fails with a checkpoint validation error:** The architecture doesn't match the base template, or a parameter is out of range. Confirm that the checkpoint is a CausalLM model, and compare its `config.json` with the base template's.
* **Training fails with a runtime error:** The checkpoint is likely corrupted or incomplete. Re-upload it to Hugging Face.
* **Model uses `trust_remote_code`:** BYOM doesn't support models that need custom code. Use a similar model that doesn't, or [contact support](https://portal.usepylon.com/together-ai/forms/support-request) to ask Together to add the model to the catalog.
* **Training fails with an internal error:** The platform notifies the Together team automatically. If the error persists, contact support with the job ID.

## FAQ

**Can I fine-tune a low-rank adapter (LoRA)?**

Yes. Pass the adapter repo as `from_hf_model` in a [LoRA job](https://docs.together.ai/docs/fine-tuning/lora-vs-full.md) whose LoRA settings (`lora_r`, `lora_alpha`, `lora_dropout`, and `lora_trainable_modules`) exactly match the adapter's configuration. Training continues from the adapter's weights on top of the base model, without merging the adapter first. The job outputs a trained adapter plus merged weights, like any other LoRA job.

**Can I train a model I uploaded for dedicated model inference?**

No. Models you [upload for dedicated model inference](https://docs.together.ai/docs/dedicated-endpoints/custom-models.md) aren't visible to the fine-tuning API. Upload the model to Hugging Face instead, and pass the repo as `from_hf_model`.

**Will my fine-tuned model work for inference?**

Yes, if the base model you specified is supported, the architecture matches, and training completes successfully. Models built on unsupported architectures may not run reliably. If you need to run one, [contact support](https://portal.usepylon.com/together-ai/forms/support-request).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.