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

# Continue a fine-tuned model

> Start a new fine-tune from a completed fine-tuned model and view its lineage with the SeekrFlow Python SDK.

For conceptual background on continued fine-tuning, including eligibility and how lineage works, see [Continued fine-tuning](https://docs.seekr.com/flow/components/fine-tuning/continued-fine-tuning.md).

> [!NOTE]
>
> Continued fine-tuning requires `seekrai` 0.37.0 or later. Upgrade with `pip install --upgrade seekrai`.

## Start a continued fine-tune

**Endpoint:** [`POST /v1/flow/fine-tune`](https://docs.seekr.com/flow/reference/fine_tune_v1_flow_fine_tune_post)

To continue a fine-tune, set `parent_finetune_id` in your `TrainingConfig` to the ID of the completed fine-tune. The new run starts from the parent's latest saved checkpoint and uses the training file and settings you provide.

The parent must be a completed fine-tune that belongs to your team and has saved checkpoints. It can be a full fine-tune or a LoRA fine-tune. The `model` parameter is optional. If you include it, it must match the parent's base model.

```python Python expandable theme={null}
from seekrai import SeekrFlow
from seekrai.types import TrainingConfig, InfrastructureConfig

client = SeekrFlow()

training_config = TrainingConfig(
    training_files=["<your-new-training-file-id>"],
    parent_finetune_id="<parent-fine-tune-id>",
    n_epochs=1,
    n_checkpoints=1,
    batch_size=4,
    learning_rate=1e-5,
    experiment_name="helperbot_v2",
)

infrastructure_config = InfrastructureConfig(
    n_accel=8,
    accel_type="MI300X",
)

fine_tune = client.fine_tuning.create(
    training_config=training_config,
    infrastructure_config=infrastructure_config,
    project_id=123,
)

print(fine_tune.id)
print(fine_tune.model)
print(fine_tune.parent_finetune_id)
```

The response includes the parent's base model in `model` and the parent's ID in `parent_finetune_id`.

You can continue with any supported training method. Set `fine_tune_type` and the method's parameters in `TrainingConfig` as you would for a new fine-tune. For example, set `fine_tune_type` to `PREFERENCE` to refine a standard fine-tune with preference training.
See [Create a fine-tuning job](https://docs.seekr.com/flow/sdk/fine-tuning/create-fine-tuning-job.md) for project setup, file upload, and monitoring.

## Continue with LoRA

To continue a LoRA fine-tune, or to continue a full fine-tune with LoRA, set `lora_config` in your `TrainingConfig`. A LoRA parent requires a `lora_config`.

```python Python expandable theme={null}
from seekrai import SeekrFlow
from seekrai.types import TrainingConfig, InfrastructureConfig
from seekrai.types.finetune import LoRAConfig

client = SeekrFlow()

training_config = TrainingConfig(
    training_files=["<your-new-training-file-id>"],
    parent_finetune_id="<parent-fine-tune-id>",
    n_epochs=1,
    n_checkpoints=1,
    batch_size=4,
    learning_rate=1e-5,
    experiment_name="helperbot_lora_v2",
    lora_config=LoRAConfig(
        r=16,
        alpha=32,
    ),
)

infrastructure_config = InfrastructureConfig(
    n_accel=8,
    accel_type="MI300X",
)

fine_tune = client.fine_tuning.create(
    training_config=training_config,
    infrastructure_config=infrastructure_config,
    project_id=123,
)

print(fine_tune.lora_adapter_merged)
print(fine_tune.lora_total_rank)
```

SeekrFlow chooses how to combine the new run with the parent, and the response reports the outcome when you create the job.

* `lora_adapter_merged` is `True` when SeekrFlow merges the adapter into full model weights. The fine-tune then deploys as its own model. The value is `False` for every other run.
* `lora_total_rank` is the total rank of the combined adapter the run ships. For example, continuing a rank 16 adapter with a rank 16 LoRA run produces a `lora_total_rank` of 32. The value is `None` when the run ships full model weights or a single adapter that wasn't combined, in which case the run's rank is its `lora_config.r`.

A full fine-tune continued with LoRA always ships full model weights, so `lora_adapter_merged` is `True`. For the full table of parent and run combinations, see [Continue with LoRA](https://docs.seekr.com/flow/components/fine-tuning/continued-fine-tuning.md#continue-with-lora).

Follow these rules when you continue with LoRA:

* Set `r` to 128 or lower. Each run's rank has a maximum of 128.
* Keep the combined rank at 256 or lower to get one adapter. The combined rank is the parent adapter's rank plus the new run's `r`. A higher combined rank produces full model weights.
* Omit `target_modules` from `extras` to train the parent's target modules. When the result is a combined adapter, the new run must train the parent's target modules.
* Use plain LoRA. The parent and the new run can't use `use_dora`, `modules_to_save`, `rank_pattern`, `alpha_pattern`, `layers_to_transform`, a `bias` other than `"none"`, or an `init_lora_weights` value other than the default or `"gaussian"`.

## View a fine-tune's lineage

**Endpoint:** [`GET /v1/flow/fine-tunes/{fine_tune_id}/lineage`](https://docs.seekr.com/flow/reference/get_fine_tune_lineage_v1_flow_fine_tunes__fine_tune_id__lineage_get)

Use `lineage` to retrieve the chain of fine-tunes a model descends from. The chain is ordered oldest first and ends with the fine-tune you request.

```python Python theme={null}
lineage = client.fine_tuning.lineage("<fine-tune-id>")

print(f"Depth: {lineage.depth}")
for node in lineage.data:
    print(f"Generation {node.generation}: {node.id} (parent: {node.parent_finetune_id})")
```

**Sample output:**

```text theme={null}
Depth: 1
Generation 0: ft-1111aaaa-0000-0000-0000-000000000000 (parent: None)
Generation 1: ft-2222bbbb-0000-0000-0000-000000000000 (parent: ft-1111aaaa-0000-0000-0000-000000000000)
```

Generation 0 is the run trained from the base model. Each node also reports `model`, `fine_tune_type`, `status`, `created_at`, and `completed_at`. For LoRA runs, each node reports `lora`, which is `True` when the run trained LoRA, along with `lora_adapter_merged` and `lora_total_rank`.

If the lineage includes deleted fine-tunes, they stay in the chain and report `deleted_at`. To retrieve the lineage of a fine-tune that you deleted, set `include_deleted=True`.

If `truncated` is `True`, the chain stops before the run trained from the base model, and `truncated_reason` states why. Check `truncated` before you treat a `depth` of `0` as a fine-tune with no parent.

Every fine-tune you retrieve with `client.fine_tuning.retrieve` or `client.fine_tuning.list` includes `parent_finetune_id`. The value is `None` for a run trained from a base model.

## Errors

| Status | Cause |
| - | - |
| 404 | The parent doesn't exist, was deleted, or belongs to another team. All three cases return the same response. |
| 422 | The parent hasn't completed, uses a different base model, or has no saved checkpoints. The message states the reason. |
| 422 | A LoRA request is invalid. The message states the reason. The cases follow this table. |
| 502 | A temporary storage error occurred while reading checkpoints. Retry shortly. |

A LoRA request returns 422 when any of these apply:

* You continue a LoRA fine-tune without a `lora_config`.
* The parent or the new run uses a LoRA option outside plain LoRA.
* The request sets `target_modules` that differ from the parent's when the result is a combined adapter.
* The LoRA parent has no recorded LoRA configuration.
* The run's `r` is over 128.

If you set neither `model` nor `parent_finetune_id`, `TrainingConfig` raises a `ValueError` before the request is sent.

## Data attribution

[Training data attribution](https://docs.seekr.com/flow/components/explainability/training-data-attribution.md) for a continued model returns only examples from the training data of that model's own training run. It never returns examples from the fine-tunes it builds on.

Training data attribution isn't available for continued fine-tunes that use preference or reinforcement tuning.


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