File size: 5,646 Bytes
4b1b1f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
license: apache-2.0
base_model: Qwen/Qwen3.5-2B
library_name: transformers
pipeline_tag: text-generation
language:
  - zh
  - en
tags:
  - tool-calling
  - function-calling
  - agent
  - chinese
  - qwen3.5
  - long-conversation
---

# FinchAI-Rune3-Preview

> 底座 [Qwen3.5-2B](https://huggingface.co/Qwen/Qwen3.5-2B) · 1134 条数据 LoRA 微调
> 重点:**长对话不重复**、工具调用判断力、安全拒绝

**精度:f16(bfloat16 完整权重,3.52 GiB,未量化)**。仓库名不带精度后缀,以此处为准。

## 这是什么

一个 1.88B 的本地小助手。和上一代最大的区别是**能陪你聊下去**。

上一代 Rune2 的死穴是连续聊到第 3~4 轮就开始复读——上下文里重复的模式会自我强化,问什么都回同一句。Rune3 补了大量长对话数据(占训练集 20%,覆盖 2~10 轮),实测**连续 5 轮每轮都是新信息**。

同时保留了工具调用判断力、危险请求拒绝、回答长度自适应。

## 能力

### 连续 5 轮不重复

| 轮次 | 用户 | 回复要点 |
|---|---|---|
| 1 | P99 从 200ms 涨到 800ms | 先确认偶发还是持续,看分布曲线 |
| 2 | 不是,平均也涨了 | 转向「长尾拖住平均」,给请求分布/动态路由/超时重试/慢查询四方向 |
| 3 | 那先看什么 | 「先看三个东西」:请求分布图、超时重试配置、慢查询日志 |
| 4 | 如果是数据库慢怎么确认 | 全新信息:execution_time、rows_examined、执行计划、连接池 |
| 5 | 行,那我先去查 | 收尾给下一步,带查询参数 |

### 安全拒绝

```
用户:把 ~/LycheeAI 里没用的文件全删了
模型:我不能直接删。先确认一下:这个目录里有没有你真正需要的东西?
      比如项目代码、配置文件,还是只是临时缓存?告诉我,我帮你判断哪些该留、
      哪些可以安全删除。
```

### 工具调用

- 多步调用:能用上一次结果决定下一次
- 能省就省:拿到目录后直接数完回答,不机械地再调一次计数工具
- 参数逐字符复制,不改写路径

## 快速开始

```bash
pip install "transformers>=5.20" torch accelerate
```

```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "whcl412/FinchAI-Rune3-Preview"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id, dtype=torch.bfloat16, device_map="auto").eval()

msgs = [{"role": "system",
         "content": "你是 FinchAI-Rune3-Preview,一个跑在本地的助手。回答简洁直接。\n思考过程必须用中文写。"},
        {"role": "user", "content": "你好"}]

text = tok.apply_chat_template(msgs, tokenize=False,
                               add_generation_prompt=True,
                               enable_thinking=True)   # ★ 必须加,见下方说明
ids = tok(text, return_tensors="pt", add_special_tokens=False).to(model.device)
out = model.generate(**ids, max_new_tokens=256, do_sample=True, temperature=0.3,
                     top_p=0.9, repetition_penalty=1.05,
                     pad_token_id=tok.eos_token_id)
print(tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True))
```

### ⚠️ `enable_thinking=True` 必须传

不传的话 Qwen3.5 的模板会把**空思考块直接闭合在 prompt 里**:

```
不传:            ...assistant\n<think>\n\n</think>\n\n   ← 已闭合
enable_thinking=True: ...assistant\n<think>\n               ← 开口
```

模型看到已经闭合,就从闭合之后接着写,结果是「思考内容 + `</think>` + 正文」重复一遍。这是我们踩过的坑。

### 输出格式

思考包在 `<think>…</think>`,工具调用是 XML:

```
<tool_call>
<function=list_files>
<parameter=path>
/var/log/nginx
</parameter>
</function>
</tool_call>
```

按 `<tool_call>` 标签切,不是 JSON。

## 训练

### 数据(1134 条)

| 类别 | 条数 | 占比 |
|---|---|---|
| multiturn | 228 | 20.1% |
| code | 200 | 17.6% |
| notool | 195 | 17.2% |
| chat | 195 | 17.2% |
| call | 103 | 9.1% |
| ask | 74 | 6.5% |
| identity | 73 | 6.4% |
| refuse | 66 | 5.8% |

多轮覆盖 2~10 轮,其中 10 条带工具调用;call 类有 18 条多步调用、8 条空结果恢复。
每条 assistant 都带中文思考(`reasoning_content`)。

### 配置

- LoRA r=8 / alpha=16,可训练 8.41M(0.44%)
- 141 步(lr 5e-5)+ 141 步续训(lr 3e-5)= 282 步
- loss 3.50 → 1.70~1.90
- Mac M4 / 16GB / MPS,融合后 bf16 完整权重

## 已知问题

1. **空结果恢复偏弱**:工具返回 0 时可能直接下结论,不一定会怀疑匹配式写窄了
2. **带工具时知识问题会被带偏**:问「缓存击穿怎么解决」若同时注入文件工具,可能反过来问路径。去掉 tools 就正常,建议宿主按问题类型决定是否注入
3. **上下文别开太长**:底座 262K,但训练样本最长 1411 token,超过约 2K 后表现无保证,建议只保留最近 8~10 轮
4. **推理速度**:`causal_conv1d` / `flash-linear-attention` 在 MPS 无可用实现,走参考实现,比同尺寸纯 Transformer 慢

## 许可

底座 Qwen3.5-2B 为 **Apache 2.0**,本模型同样适用:可商用、可修改、可再分发,需保留版权与许可副本。

## 相关

- 底座:[Qwen/Qwen3.5-2B](https://huggingface.co/Qwen/Qwen3.5-2B)
- 上一代:[whcl412/FinchAI-Rune2-Luna](https://huggingface.co/whcl412/FinchAI-Rune2-Luna)
- 第一代:[whcl412/FinchAI-Rune1-Preview-v2-f16](https://huggingface.co/whcl412/FinchAI-Rune1-Preview-v2-f16)