Tune diffusion cap and tighten evidence/entity section rules
This commit is contained in:
@@ -55,7 +55,6 @@ const TOP_N_STAR = 5;
|
|||||||
// L0 显示文本:分号拼接 vs 多行模式的阈值
|
// L0 显示文本:分号拼接 vs 多行模式的阈值
|
||||||
const L0_JOINED_MAX_LENGTH = 120;
|
const L0_JOINED_MAX_LENGTH = 120;
|
||||||
// 背景证据:无实体匹配时保留的最低相似度(与 recall.js CONFIG.EVENT_ENTITY_BYPASS_SIM 保持一致)
|
// 背景证据:无实体匹配时保留的最低相似度(与 recall.js CONFIG.EVENT_ENTITY_BYPASS_SIM 保持一致)
|
||||||
const EVIDENCE_ENTITY_BYPASS_SIM = 0.70;
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
// 工具函数
|
// 工具函数
|
||||||
@@ -161,14 +160,18 @@ function collectL0Entities(l0) {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function shouldKeepEvidenceL0(l0, focusSet) {
|
function shouldKeepEvidenceL0(l0, focusSet) {
|
||||||
if (!focusSet?.size) return true;
|
if (!focusSet?.size) return false;
|
||||||
if ((l0?.similarity || 0) >= EVIDENCE_ENTITY_BYPASS_SIM) return true;
|
|
||||||
|
|
||||||
const entities = collectL0Entities(l0);
|
const entities = collectL0Entities(l0);
|
||||||
for (const f of focusSet) {
|
for (const f of focusSet) {
|
||||||
if (entities.has(f)) return true;
|
if (entities.has(f)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 兼容旧数据:semantic 文本包含焦点实体
|
||||||
|
const textNorm = normalize(l0?.atom?.semantic || l0?.text || '');
|
||||||
|
for (const f of focusSet) {
|
||||||
|
if (f && textNorm.includes(f)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +211,7 @@ function buildSystemPreamble() {
|
|||||||
"以上是还留在眼前的对话",
|
"以上是还留在眼前的对话",
|
||||||
"以下是脑海里的记忆:",
|
"以下是脑海里的记忆:",
|
||||||
"• [定了的事] 这些是不会变的",
|
"• [定了的事] 这些是不会变的",
|
||||||
|
"• [其他人的事] 别人的经历,当前角色可能不知晓",
|
||||||
"• 其余部分是过往经历的回忆碎片",
|
"• 其余部分是过往经历的回忆碎片",
|
||||||
"",
|
"",
|
||||||
"请内化这些记忆:",
|
"请内化这些记忆:",
|
||||||
@@ -1051,7 +1055,7 @@ async function buildVectorPrompt(store, recallResult, causalById, focusEntities,
|
|||||||
sections.push(`[印象深的事] 记得很清楚\n\n${assembled.directEvents.lines.join("\n\n")}`);
|
sections.push(`[印象深的事] 记得很清楚\n\n${assembled.directEvents.lines.join("\n\n")}`);
|
||||||
}
|
}
|
||||||
if (assembled.relatedEvents.lines.length) {
|
if (assembled.relatedEvents.lines.length) {
|
||||||
sections.push(`[好像有关的事] 听说过或有点模糊\n\n${assembled.relatedEvents.lines.join("\n\n")}`);
|
sections.push(`[其他人的事] 别人经历的类似事\n\n${assembled.relatedEvents.lines.join("\n\n")}`);
|
||||||
}
|
}
|
||||||
if (assembled.distantEvidence.lines.length) {
|
if (assembled.distantEvidence.lines.length) {
|
||||||
sections.push(`[零散记忆] 没归入事件的片段\n${assembled.distantEvidence.lines.join("\n")}`);
|
sections.push(`[零散记忆] 没归入事件的片段\n${assembled.distantEvidence.lines.join("\n")}`);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ const CONFIG = {
|
|||||||
// Post-verification (Cosine Gate)
|
// Post-verification (Cosine Gate)
|
||||||
COSINE_GATE: 0.45, // min cosine(queryVector, stateVector)
|
COSINE_GATE: 0.45, // min cosine(queryVector, stateVector)
|
||||||
SCORE_FLOOR: 0.10, // min finalScore = PPR_normalized × cosine
|
SCORE_FLOOR: 0.10, // min finalScore = PPR_normalized × cosine
|
||||||
DIFFUSION_CAP: 60, // max diffused nodes (excluding seeds)
|
DIFFUSION_CAP: 100, // max diffused nodes (excluding seeds)
|
||||||
};
|
};
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
|||||||
Reference in New Issue
Block a user