From 7f8f1bf9efe28e6cd76082d475847fc46112457b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B4=AB=E5=BD=B1233?= Date: Wed, 24 Jun 2026 15:58:21 +0800 Subject: [PATCH] =?UTF-8?q?tune:=20=E5=8E=BB=E9=87=8D=E9=98=88=E5=80=BC?= =?UTF-8?q?=E6=94=B6=E7=B4=A7=20=E2=80=94=20similarity=200.8=E2=86=920.65?= =?UTF-8?q?=20(=E6=96=B0=E5=A2=9E)=20/=200.75=E2=86=920.6=20(=E6=8F=90?= =?UTF-8?q?=E5=8F=96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原则:宁愿少记,不要重复多记。降低相似度阈值让更多近似内容被判为重复。 --- src/renderer/services/memory-service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/services/memory-service.ts b/src/renderer/services/memory-service.ts index 6c5efbc..267ecdb 100644 --- a/src/renderer/services/memory-service.ts +++ b/src/renderer/services/memory-service.ts @@ -451,8 +451,8 @@ export async function addEntry( // 2) 如果短文本,检查子串包含 if (normalizedNew.length < 40 && normalizedExisting.includes(normalizedNew)) return true; if (normalizedExisting.length < 40 && normalizedNew.includes(normalizedExisting)) return true; - // 3) 词级相似度 - return simpleSimilarity(normalizedExisting, normalizedNew) > 0.8; + // 3) 词级相似度 — 阈值 0.65:宁愿少记也不重复 + return simpleSimilarity(normalizedExisting, normalizedNew) > 0.65; }); if (existing) { logDebug('记忆去重: 已有相同条目', `${type}: ${content.slice(0, 40)}`); @@ -780,7 +780,7 @@ ${conversationText.slice(0, 5000)} if (prefixLen > 10 && normalizedNew.slice(0, prefixLen) === normalizedExisting.slice(0, prefixLen)) return true; if (normalizedNew.length < 40 && normalizedExisting.includes(normalizedNew)) return true; if (normalizedExisting.length < 40 && normalizedNew.includes(normalizedExisting)) return true; - return simpleSimilarity(normalizedExisting, normalizedNew) > 0.75; + return simpleSimilarity(normalizedExisting, normalizedNew) > 0.6; }); if (isDuplicate) { logDebug('自动记忆过滤: 重复', entry.content.slice(0, 40));