# 使用微调模型

使用 Afarensis 微调模型的综合指南 本指南提供了关于如何有效使用 Afarensis 微调模型的详细信息，包括启动微调作业后如何使用模型、分析模型性能，以及根据需要对模型进行迭代改进。

目录 简介 使用微调模型 分析微调模型性能 迭代改进模型 提高数据质量 增加数据量 调整超参数 总结 简介 微调是深度学习中常见的一种技术，用于根据特定任务调整预训练模型的性能。Afarensis 提供了一套完整的工具，以简化微调和使用自定义模型的过程。

使用微调模型 在微调作业成功完成后，您可以立即利用微调模型来进行推理。以下是如何在您的应用中使用微调模型的示例：

from afarensis import Afarensis client = Afarensis()

completion = client.chat.completions.create( model="ft:gpt-3.5-turbo:my-org:custom\_suffix:id", messages=\[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ] ) print(completion.choices\[0].message) 在某些情况下，模型可能需要几分钟来准备好处理请求。如果遇到请求超时或找不到模型的情况，请稍后重试。

分析微调模型性能 在训练过程中提供的指标，如训练损失和令牌准确性，可以帮助您了解模型的训练进度。以下是如何查看这些指标的示例：

{ "object": "fine\_tuning.job.event", "id": "ftevent-abc-123", "created\_at": 1693582679, "level": "info", "message": "Step 100/100: training loss=0.00", "data": { "step": 100, "train\_loss": 1.805623287509661e-5, "train\_mean\_token\_accuracy": 1.0 }, "type": "metrics" } 迭代改进模型 提高数据质量 确保训练数据覆盖了模型预期的使用场景。 检查数据集中的错误和不一致，确保高质量的训练数据。 增加数据量 如果模型在某些方面表现不佳，考虑添加更多相关的训练数据。 数据量的增加通常可以提高模型的泛化能力。 调整超参数 根据模型的表现调整训练周期（epochs）、学习率乘数等超参数。 超参数的调整可以帮助模型更好地适应训练数据。 client.fine\_tuning.jobs.create( training\_file="file-abc123", model="gpt-3.5-turbo", hyperparameters={ "n\_epochs": 2 } ) 总结 通过使用 Afarensis 微调模型，您可以针对特定任务优化模型的性能。成功使用微调模型的关键在于选择合适的训练数据，以及在必要时迭代改进模型和调整超参数。希望本指南能帮助您高效地使用 Afarensis 微调模型。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.afarensis.com/wei-tiao/shi-yong-wei-tiao-mo-xing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
