Knowledge Lifecycle
Knowledge Lifecycle 是管理知识从创建、更新、归档到删除的完整生命周期。知识会过时,需要定期更新和清理。
#type / concept
#status / evergreen
#tech / ai
[!info] related notes
- 所属 MOC: RAG Engineering MOC
- 相关: Document Ingestion
Knowledge Lifecycle
一句话定义
Knowledge Lifecycle 是管理知识从创建、更新、归档到删除的完整生命周期。去年的退款政策可能已经变了,过时的知识会导致错误的回答。
核心原理
生命周期阶段
创建 → 审核 → 发布 → 更新 → 过期 → 归档/删除
知识状态管理
class KnowledgeLifecycleManager:
async def create(self, document: Document):
"""创建新知识"""
doc_id = await self.store.save(document, status="draft")
await self.notify_reviewer(doc_id)
return doc_id
async def approve(self, doc_id: str):
"""审核通过"""
await self.store.update_status(doc_id, "published")
await self.reindex(doc_id)
async def update(self, doc_id: str, new_content: str):
"""更新知识"""
await self.store.update(doc_id, new_content)
await self.reindex(doc_id)
async def expire(self, doc_id: str):
"""标记过期"""
await self.store.update_status(doc_id, "expired")
await self.deindex(doc_id)
async def reindex(self, doc_id: str):
"""重新索引(重新生成 Embedding)"""
doc = await self.store.get(doc_id)
chunks = self.chunker.chunk(doc)
embeddings = await self.embedder.embed_batch([c.text for c in chunks])
await self.vector_store.upsert(chunks, embeddings)
过期检测
async def check_freshness():
"""检查知识新鲜度"""
expired = await db.query("""
SELECT * FROM knowledge
WHERE status = 'published'
AND updated_at < NOW() - INTERVAL '90 days'
""")
for doc in expired:
await notify_owner(doc)
常见坑
- 不做更新: 知识过时导致错误回答
- 不重新索引: 更新了文档但向量没有更新
- 不做过期检测: 永远不过期的知识可能已经不准确