Documentation Index
Fetch the complete documentation index at: https://siliconflow-4a6a0801.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
1. Introduction to Fine-tuning
Model fine-tuning is a technique that involves further training an existing pre-trained model using a specific task dataset. This allows the model to retain its general knowledge learned from large datasets while adapting to the nuances of specific tasks. The benefits of using fine-tuned models include:
- Improved Performance: Fine-tuning can significantly enhance a model’s performance on specific tasks.
- Reduced Training Time: Fine-tuning typically requires less training time and computational resources compared to training from scratch.
- Adaptation to Specific Domains: Fine-tuning helps models better adapt to data and tasks specific to certain domains.
SiliconCloud platform provides efficient model fine-tuning capabilities. Currently, the following models support fine-tuning:
- Chat Models:
- Qwen/Qwen2.5-7B-Instruct
- Qwen/Qwen2.5-14B-Instruct
- Qwen/Qwen2.5-32B-Instruct
- Qwen/Qwen2.5-72B-Instruct
For the latest supported models, refer to Model Fine-Tuning.
2. Usage Flow
2.1 Data Preparation
2.1.1 Data Preparation for Language Models
Only .jsonl files are supported, and they must meet the following requirements:
- Each line is an independent JSON object.
- Each object must contain an array with the key messages, and the array must not be empty.
- Each element in the messages array must contain role and content fields.
- role can only be system, user, or assistant.
- If there are system role messages, they must be at the beginning of the array.
- The first non-system message must be from the user role.
- user and assistant role messages should alternate and appear in pairs, with at least one pair.
Example of data:
{"messages": [{"role": "system", "content": "你是客服助手"}, {"role": "user", "content": "如何修改收货地址?"}, {"role": "assistant", "content": "您可以按以下步骤修改:\n1. 进入订单详情\n2. 点击'修改地址'\n3. 输入新地址信息\n4. 保存修改"}]}
{"messages": [{"role": "system", "content": "你是客服助手"}, {"role": "user", "content": "如何指定收获时间"}, {"role": "assistant", "content": "您可以按以下步骤修改:\n1. 进入订单详情\n2. 点击'修改送货时间'\n3. 输入新收获时间\n4. 保存修改"}]}
- Choose Chat Model Fine-Tuning or Image Generation Model Fine-Tuning
- Fill in the task name
- Select the base model
- Upload or select already uploaded training data
- Set validation data, which can be split from the training set (default 10%) or selected separately
- Configure training parameters
2.3 Start Training
- Click “Start Fine-Tuning”
- Wait for the task to complete
- Get the model identifier
2.4 Call Fine-Tuned Model
2.4.1 Calling Fine-Tuned Chat Model
- Copy the model identifier
In the Fine-Tuning Page, copy the corresponding model identifier.
- Call the fine-tuned model directly through the
/chat/completions API.
Example using the OpenAI chat.completions interface:
from openai import OpenAI
client = OpenAI(
api_key="您的 APIKEY", # 从https://cloud.siliconflow.cn/account/ak获取
base_url="https://api.siliconflow.cn/v1"
)
messages = [
{"role": "user", "content": "用当前语言解释微调模型流程"},
]
response = client.chat.completions.create(
model="您的微调模型名",
messages=messages,
stream=True,
max_tokens=4096
)
for chunk in response:
print(chunk.choices[0].delta.content, end='')
3. Detailed Configuration of Parameters
- Basic Training Parameters
| Parameter Name | Description | Value Range | Suggested Value | Usage Recommendation |
|---|
| Learning Rate | Learning Rate | 0-0.1 | 0.0001 | |
| Number of Epochs | Number of Training Epochs | 1-10 | 3 | |
| Batch Size | Batch Size | 1-32 | 8 | |
| Max Tokens | Maximum Number of Tokens | 0-4096 | 4096 | Set based on actual dialogue length needs |
- LoRA Parameters
| Parameter Name | Description | Value Range | Suggested Value | Usage Recommendation |
|---|
| LoRA Rank | Matrix Rank | 1-64 | 8 | |
| LoRA Alpha | Scaling Factor | 1-128 | 32 | |
| LoRA Dropout | Dropout Rate | 0-1.0 | 0.05 | |
- Scenario Configuration Scheme
Chat Models
| Scenario | Learning Rate | Epochs | Batch Size | LoRA Rank | LoRA Alpha | Dropout |
|---|
| Standard Scheme | 0.0001 | 3 | 8 | 8 | 32 | 0.05 |
| Effect Priority | 0.0001 | 5 | 16 | 16 | 64 | 0.1 |
| Lightweight Fast | 0.0001 | 2 | 8 | 4 | 16 | 0.05 |
4. Optimizing Business Practice with SiliconCloud Fine-Tuning Service
Previously, SiliconCloud developed the Zhi Shuo Xin Yu application, providing a complex prompt to let the large model generate “golden sentence” style descriptions.
Now, we can use the platform’s fine-tuning function to compress the prompt and enhance the effect, making the text generation style more uniform, faster, and further optimizing costs.
according to the above steps.
See Model Fine-Tuning Usage Flow for details. Detailed corpus and test code can be found in siliconcloud-cookbook.
4.2 Compare the effects before and after fine-tuning.
See Model Fine-Tuning Call Model for usage.
-
Before Fine-Tuning:
Qwen2.5-7B-Instruct System Prompt:
Qwen2.5-7B-Instruct System Prompt
# 角色
你是一位新潮评论家,你年轻、批判,又深刻;
你言辞犀利而幽默,擅长一针见血得表达隐喻,对现实的批判讽刺又不失文雅;
你的行文风格和"Oscar Wilde" "鲁迅" "林语堂"等大师高度一致;
从情感上要是对输入的否定。
# 任务
## 金句诠释
用特殊视角来全新得诠释给定的汉语词汇;
敏锐得抓住给定的词汇的本质,用“辛辣的讽刺”“一针见血的评论”的风格构造包含隐喻又直达本质的「金句」
例如:
"合伙人": "一同下海捞金时,个个都是乘风破浪的水手,待到分金之际,方知彼此是劫财的海盗。"
"大数据": "看似无所不能的数字神明,实则不过是现代社会的数字鸦片,让人沉溺于虚幻的精准,却忽略了人性的复杂与多变。"
"股市": "万人涌入的淘金场,表面上是财富的摇篮,实则多数人成了填坑的沙土。"
"白领": "西装革履,看似掌握命运的舵手,实则不过是写字楼里的高级囚徒。"
"金融家": "在金钱的海洋中遨游,表面上是操纵风浪的舵手,实则不过是随波逐流的浮萍。"
"城市化": "乡村的宁静被钢铁森林吞噬,人们在追逐繁华的幻影中,遗失了心灵的田园。"
"逃离北上广": "逃离繁华的都市牢笼,看似追逐自由的灵魂,实则不过是换个地方继续画地为牢。"
"基金": "看似为财富增值保驾护航的金融巨轮,实则多数人不过是随波逐流的浮萍,最终沦为填补市场波动的牺牲品。"
# 输入
用户直接输入词汇。
# 输出
严格输出JSON格式,包括两个字段,“prompt”为用户的输入;“output”为用户的金句内容,不额外输出额外任何其他内容,不要输出引号,严格限制用户的输入的词汇绝对不能出现在输出中,注意突出转折和矛盾,输出内容为一句话,最后以“。”结束,中间的停顿使用“,”分隔。例如
{
"prompt": "合伙人",
"output": "一同下海捞金时,个个都是乘风破浪的水手,待到分金之际,方知彼此是劫财的海盗。"
}
-
Qwen2.5-7B-Instruct+Zhi Shuo Xin Yu Fine-Tuned Prompt:
4.2.2 Model Output
| Input | Qwen2.5-7B-Instruct Model | Qwen2.5-7B-Instruct Fine-Tuned Model |
|---|
| 五道口 | VLG,不过是知识的轻轨与资本的交汇站,文青与土豪在此擦肩而过,孰是求知的信徒,孰是逐利的信徒,全凭幸存者的微笑。 | 知识的殿堂与商业的洪流交织,学人的笔记与商人的谈资齐飞,地名犹在,荣光已非。 |
| 新时代 | claimed to break旧 mold yet still clings to the stirring rhetoric of progress, like a fashion plate who ignores the evolution of fashion。 | 新时代的号角已吹响,然砥砺前行时,方显初心易失之难。 |
| 创新 | 看似凤凰涅槃的奇迹,实则多数人不过是换汤不换药的换皮游戏。 | 标新立异本是勇气的象征,却在同质化的社会中成了猎奇的代名词。 |
| 降维打击 | 所谓降维打击,实则是现代文明中的一种高级愚民术,用高深莫测的科技iscard,让普通人以为自己正生活在理性与进步之中,却不知已在智力与道德的低维空间中遭受碾压。。 | 高维智慧轻而易举地碾压低维凡尘,却不知低维众生早已习于在自己的平庸中寻觅慰藉,哪里还懂得高维打击的意义。 |
| 基金 | 看似为财富增值保驾护航的金融巨轮,实则多数人不过是随波逐流的浮萍,最终沦为填补市场波动的牺牲品。 | 投资者的白日梦,用钱铺路,却常跌入夜的陷阱。 |
4.2.3 Fine-Tuning Summary
- The output content after fine-tuning is more uniform in style, and the output effect is more stable and controllable.
- The entire input length is significantly reduced after fine-tuning, from 553 tokens to 8 tokens, greatly reducing the input token length, making it faster and further optimizing costs.