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

# Fine-Tuning

> Understand what fine-tuning changes, when to use it, and how to evaluate a trained model safely.

# Fine-Tuning

Fine-tuning continues the training of a supported base model on examples for a specific task. It can reinforce response patterns, terminology, style, or output structure. It does not automatically add reliable, current knowledge and it does not guarantee better results.

Model and provider support varies. Confirm the available base models, data format, limits, and costs in your B-Bot Hub configuration before preparing a dataset.

## Choose the Right Method

<CardGroup cols={3}>
  <Card title="System Prompt" icon="message">
    Use for instructions, priorities, tone, boundaries, and behavior that may change.
  </Card>

  <Card title="Knowledge Retrieval" icon="book">
    Use for source material that must stay current, traceable, or easy to replace.
  </Card>

  <Card title="Fine-Tuning" icon="microchip">
    Use for repeated examples of the behavior or output pattern you want the model to learn.
  </Card>
</CardGroup>

Try prompt and knowledge improvements first. Consider fine-tuning when you have a stable task, a measurable gap, representative examples, and a supported model.

## Fine-Tuning Workflow

<Steps>
  <Step title="Define the Target">
    Write a narrow improvement goal, such as following a response schema or applying a consistent support style.
  </Step>

  <Step title="Create an Evaluation Set">
    Prepare representative test cases before training. Keep them separate from training examples.
  </Step>

  <Step title="Prepare Examples">
    Use clear inputs and reviewed ideal outputs. Include normal cases, difficult cases, and appropriate refusals.
  </Step>

  <Step title="Review the Dataset">
    Remove duplicates, contradictions, sensitive data, outdated facts, and examples that reward unsupported claims.
  </Step>

  <Step title="Train a Version">
    Select a supported base model and use the training controls available in B-Bot Hub.
  </Step>

  <Step title="Compare and Decide">
    Evaluate the base and trained versions on the same held-out cases. Adopt the trained version only when it improves the defined target without unacceptable regressions.
  </Step>
</Steps>

## Dataset Principles

* **Representative:** Match real inputs, including their length and ambiguity.
* **Consistent:** Resolve conflicts in tone, policy, and expected behavior.
* **Complete:** Include enough context for the desired answer.
* **Current:** Remove stale policies, product details, and links.
* **Safe:** Exclude secrets and personal data unless collection and use are approved.
* **Balanced:** Include cases where the correct behavior is to ask, refuse, or escalate.

There is no universal number of examples that guarantees a useful model. Start with a reviewed dataset, measure the result, and add examples that address observed gaps.

## Evaluation

Evaluate dimensions separately:

* Task success and factual accuracy
* Instruction and format compliance
* Appropriate uncertainty and refusal
* Robustness to paraphrases and edge cases
* Regressions outside the target behavior
* Latency and cost in the intended environment

Record the dataset version, base model, configuration, and evaluation results so the decision can be reproduced.

## Common Mistakes

<AccordionGroup>
  <Accordion title="Using Fine-Tuning as a Knowledge Database" icon="database">
    Frequently changing facts are usually easier to maintain in a knowledge source or request context.
  </Accordion>

  <Accordion title="Training and Testing on the Same Examples" icon="flask">
    This measures memorization, not performance on new requests. Keep a separate evaluation set.
  </Accordion>

  <Accordion title="Accepting Synthetic Data Without Review" icon="triangle-exclamation">
    Generated examples can contain errors and repeated patterns. Review them before training.
  </Accordion>

  <Accordion title="Assuming Improvement" icon="chart-line">
    A completed training job is not evidence of better behavior. Compare against the base model.
  </Accordion>
</AccordionGroup>

## Related Guides

<CardGroup cols={2}>
  <Card title="Training Guide" icon="graduation-cap" href="/essentials/training">
    Use the B-Bot Hub training interface.
  </Card>

  <Card title="Model Distillation" icon="flask" href="/concepts/fine-tuning/model-distillation">
    Learn how teacher-generated examples can support a fine-tuning dataset.
  </Card>
</CardGroup>
