Skip to content

Commit 6a99822

Browse files
committed
简化日志召回
1 parent bed3d0d commit 6a99822

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

KnowledgeBaseManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ class KnowledgeBaseManager {
453453
* 🌟 TagMemo 浪潮 + EPA + Residual Pyramid + Worldview Gating + LIF Spike Propagation (V6)
454454
*/
455455
_applyTagBoostV6(vector, baseTagBoost, coreTags = [], coreBoostFactor = 1.33) {
456-
const debug = true;
456+
const debug = false;
457457
const originalFloat32 = vector instanceof Float32Array ? vector : new Float32Array(vector);
458458
const dim = originalFloat32.length;
459459

Plugin/RAGDiaryPlugin/RAGDiaryPlugin.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,6 @@ class RAGDiaryPlugin {
16611661

16621662
const sim = this.cosineSimilarity(queryVector, diaryVec);
16631663
diaryScores.push({ name, similarity: sim });
1664-
console.log(`[RAGDiaryPlugin] → "${name}" 相似度: ${sim.toFixed(4)}`);
16651664
} catch (e) {
16661665
console.error(`[RAGDiaryPlugin] 聚合模式: 获取 "${name}" 向量时出错:`, e.message);
16671666
// 不崩溃,继续处理其他日记本
@@ -1694,11 +1693,9 @@ class RAGDiaryPlugin {
16941693
};
16951694
});
16961695

1697-
// 日志输出分配结果
1698-
console.log(`[RAGDiaryPlugin] 🌟 K 分配结果:`);
1699-
kAllocations.forEach(a => {
1700-
console.log(`[RAGDiaryPlugin] → "${a.name}": sim=${a.similarity.toFixed(4)}, weight=${(a.weight * 100).toFixed(1)}%, k=${a.k}`);
1701-
});
1696+
// 日志输出分配结果(简化)
1697+
console.log(`[RAGDiaryPlugin] K分配: ${kAllocations.map(a => `"${a.name}"(k=${a.k})`).join(', ')}`);
1698+
17021699

17031700
// --- Step 3: 并行调用各日记本的检索 ---
17041701
// 🛡️ 去除 modifiers 中的 kMultiplier,防止 _processRAGPlaceholder 内部再次乘以 kMultiplier
@@ -1893,7 +1890,6 @@ class RAGDiaryPlugin {
18931890
}
18941891

18951892
// 3️⃣ 缓存未命中,执行原有逻辑
1896-
console.log(`[RAGDiaryPlugin] 缓存未命中,执行RAG检索...`);
18971893

18981894
const kMultiplier = this._extractKMultiplier(modifiers);
18991895
const useTime = allowTimeAndGroup && modifiers.includes('::Time');
@@ -1960,7 +1956,7 @@ class RAGDiaryPlugin {
19601956
const rawTags = boostResult.info.matchedTags;
19611957
// 🌟 应用截断技术规避尾部噪音
19621958
coreTagsForSearch = this._truncateCoreTags(rawTags, tagTruncationRatio, metrics);
1963-
console.log(`[RAGDiaryPlugin] 🌟 原子级复刻成功!感应到核心 Tag: [${coreTagsForSearch.join(', ')}]${rawTags.length > coreTagsForSearch.length ? ` (从 ${rawTags.length} 个截断)` : ''}`);
1959+
console.log(`[RAGDiaryPlugin] TagBoost: ${coreTagsForSearch.length}个核心Tag${rawTags.length > coreTagsForSearch.length ? ` (从${rawTags.length}截断)` : ''}`);
19641960
}
19651961
} catch (e) {
19661962
console.warn('[RAGDiaryPlugin] Failed to sense tags via applyTagBoost:', e.message);
@@ -1975,7 +1971,6 @@ class RAGDiaryPlugin {
19751971
const kSemantic = Math.max(1, Math.ceil(finalK * 0.6));
19761972
const kTime = Math.max(1, finalK - kSemantic);
19771973

1978-
console.log(`[RAGDiaryPlugin] 🌟 Time-Aware Balanced Mode: Total K=${finalK} (Semantic=${kSemantic}, Time=${kTime})`);
19791974

19801975
// 1. 语义路召回
19811976
let ragResults = await this.vectorDBManager.search(dbName, finalQueryVector, kSemantic + dedupBuffer, tagWeight, coreTagsForSearch);
@@ -2551,7 +2546,6 @@ class RAGDiaryPlugin {
25512546
return documents.slice(0, originalK);
25522547
}
25532548

2554-
console.log(`[RAGDiaryPlugin] Rerank processing ${batches.length} batches with truncated query (${queryTokens} tokens)`);
25552549

25562550
let allRerankedDocs = [];
25572551
let failedBatches = 0;
@@ -2665,11 +2659,8 @@ class RAGDiaryPlugin {
26652659
const finalDocs = allRerankedDocs.slice(0, originalK);
26662660
const successRate = ((batches.length - failedBatches) / batches.length * 100).toFixed(1);
26672661

2668-
// 详细日志:展示每条文档的双路排位和融合结果
2669-
console.log(`[RAGDiaryPlugin] 🌟 Rerank+ (RRF) 完成: ${finalDocs.length}篇文档 (α=${alpha}, 成功率: ${successRate}%)`);
2670-
finalDocs.forEach((doc, idx) => {
2671-
console.log(` [RRF #${idx + 1}] rrf=${doc.rrf_score?.toFixed(6)} | retrieval_rank=${doc.retrieval_rank} | rerank_rank=${doc.rerank_rank} | rerank_score=${doc.rerank_score?.toFixed(4) ?? 'N/A'} | vec_score=${doc.score?.toFixed(4) ?? 'N/A'}`);
2672-
});
2662+
// 注意: RRF详细日志已精简
2663+
console.log(`[RAGDiaryPlugin] Rerank+(RRF): ${finalDocs.length}篇 (α=${alpha}, 成功率${successRate}%)`);
26732664

26742665
return finalDocs;
26752666
} else {
@@ -2910,7 +2901,10 @@ class RAGDiaryPlugin {
29102901
timestamp: Date.now()
29112902
});
29122903

2913-
console.log(`[RAGDiaryPlugin] 缓存已保存 (当前: ${this.queryResultCache.size}/${this.maxCacheSize})`);
2904+
// 每10次保存才输出一次日志,减少噪音
2905+
if (this.queryResultCache.size % 10 === 0) {
2906+
console.log(`[RAGDiaryPlugin] 缓存: ${this.queryResultCache.size}/${this.maxCacheSize}`);
2907+
}
29142908
}
29152909

29162910
/**
@@ -2966,7 +2960,6 @@ class RAGDiaryPlugin {
29662960
if (cached) {
29672961
const now = Date.now();
29682962
if (now - cached.timestamp <= this.embeddingCacheTTL) {
2969-
console.log(`[RAGDiaryPlugin] ✅ 向量缓存命中 (键: ${cacheKey.substring(0, 8)}...)`);
29702963
return cached.vector;
29712964
} else {
29722965
// 过期,删除
@@ -2975,7 +2968,6 @@ class RAGDiaryPlugin {
29752968
}
29762969

29772970
// 缓存未命中,调用API
2978-
console.log(`[RAGDiaryPlugin] 向量缓存未命中,调用Embedding API...`);
29792971
const vector = await this.getSingleEmbedding(text);
29802972

29812973
if (vector) {

0 commit comments

Comments
 (0)