pi-think-anchor 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +6 -2
- package/README.md +2 -2
- package/index.ts +5 -5
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -19,12 +19,16 @@ Measures the "focus fingerprint" of thinking and nudges the model back when it d
|
|
|
19
19
|
| Window | 5 turns | sliding |
|
|
20
20
|
| L1 cooldown | 10 min | first drift |
|
|
21
21
|
| L2 cooldown | 15 min | sustained drift, max 2 per session |
|
|
22
|
-
| Word lists | Chinese | 28 focus /
|
|
22
|
+
| Word lists | Chinese | 28 focus / 18 drift terms |
|
|
23
|
+
|
|
24
|
+
## Credits
|
|
25
|
+
|
|
26
|
+
Distilled from [dsh-anchored-monitor](https://dsh-plugin.org/zh/plugins/aik358/dsh-anchored-monitor) 0.3.1 (DSH ecosystem): the mechanism idea only, no code port — per-turn evaluation instead of live streaming, no separate process. Thresholds calibrated against 6151 logged turns.
|
|
23
27
|
|
|
24
28
|
## Install
|
|
25
29
|
|
|
26
30
|
```bash
|
|
27
|
-
pi install npm:pi-think-anchor
|
|
31
|
+
pi install npm:pi-think-anchor
|
|
28
32
|
pi install ./pi-think-anchor
|
|
29
33
|
```
|
|
30
34
|
|
package/README.md
CHANGED
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
| 启用 | 开 | `THINK_ANCHOR=0` 或配置文件 `enabled: false` 关闭 |
|
|
22
22
|
| 波段阈值 | 1.2 / 0.5 | α 平滑比率:高专注 ≥1.2;发散 <0.5 |
|
|
23
23
|
| 证据门槛 | 3 命中/轮 | 本轮词频命中不足 3 个 → 不评分、不干预 |
|
|
24
|
-
| 聚合窗口 | 5
|
|
24
|
+
| 聚合窗口 | 5 条消息 | 滑动窗口(长工具链中约 1 轮) |
|
|
25
25
|
| L1 冷却 | 10 分钟 | 首次跌入发散 |
|
|
26
26
|
| L2 冷却 | 15 分钟 | 持续发散,会话上限 2 次 |
|
|
27
|
-
| 词表 | 中文 | 专注 28 词 / 发散
|
|
27
|
+
| 词表 | 中文 | 专注 28 词 / 发散 18 词 |
|
|
28
28
|
|
|
29
29
|
## 安装
|
|
30
30
|
|
package/index.ts
CHANGED
|
@@ -110,10 +110,10 @@ export function bandOf(ratio: number, bands: { spec: number; react: number } = D
|
|
|
110
110
|
* α=1(伪计数)+ minHits=3 后 react 占 9.7%,且选中样本 negRate 中位 0.86(真发散)。
|
|
111
111
|
* α 的作用:低命中时比率趋向 1(mixed),不再因「命中少」被误判成 react。
|
|
112
112
|
*/
|
|
113
|
-
export function classify(pos: number, neg: number, neu: number, c: { minHits: number; spec: number; react: number; alpha: number }): TABand {
|
|
113
|
+
export function classify(pos: number, neg: number, neu: number, c: { minHits: number; spec: number; react: number; alpha: number; beta?: number; eps?: number }): TABand {
|
|
114
114
|
const hits = pos + neg + neu;
|
|
115
115
|
if (hits < c.minHits) return "none";
|
|
116
|
-
const r = (pos + 0.4 * neu + c.alpha) / (neg + 0.5 + c.alpha);
|
|
116
|
+
const r = (pos + (c.beta ?? 0.4) * neu + c.alpha) / (neg + (c.eps ?? 0.5) + c.alpha);
|
|
117
117
|
if (r < c.react) return "react";
|
|
118
118
|
if (r < c.spec) return "mixed";
|
|
119
119
|
return "spec";
|
|
@@ -224,7 +224,7 @@ function newState(cfg: TAConfig): TAState {
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
/** 采样写盘(v3):非事件轮每 5
|
|
227
|
+
/** 采样写盘(v3):非事件轮每 5 条 assistant 消息留一行——实测 6151 行 / 1.0 MB 逼近 1 MiB 上限,降为 1/5 仍够统计 */
|
|
228
228
|
const SAMPLE_EVERY = 5;
|
|
229
229
|
/** 自适应(v3):有效样本 ≥ AUTO_MIN 且下降率 < AUTO_RATE(不及抛硬币)即转静默,只记录不注入 */
|
|
230
230
|
const AUTO_MIN = 8;
|
|
@@ -294,9 +294,9 @@ export default function thinkAnchor(pi: ExtensionAPI): void {
|
|
|
294
294
|
lastHits = hits;
|
|
295
295
|
lastNegRate = negRate;
|
|
296
296
|
const ratio = ratioOf(agg.pos, agg.neg, agg.neu, st.cfg.weights);
|
|
297
|
-
const band = classify(agg.pos, agg.neg, agg.neu, st.cfg.score);
|
|
297
|
+
const band = classify(agg.pos, agg.neg, agg.neu, { ...st.cfg.score, ...st.cfg.weights });
|
|
298
298
|
const prevPhase = st.phase;
|
|
299
|
-
const r = (agg.pos +
|
|
299
|
+
const r = (agg.pos + st.cfg.weights.beta * agg.neu + st.cfg.score.alpha) / (agg.neg + st.cfg.weights.eps + st.cfg.score.alpha);
|
|
300
300
|
const d0 = decideNext(st.phase, band, st.l2Tried, st.cfg.intervention.maxL2);
|
|
301
301
|
// 升级前先看上次干预有没有用:无效则本次不升 L2(实测 L2 无收益)
|
|
302
302
|
const d = { ...d0, level: downgradeIfIneffective(d0.level, lastEffValue) };
|