语义相似度检索有缺陷,graph-aware 检索怎么用
svpino 用会议改期这个例子讲清了 flat 检索为什么不行,Oracle AI Agent Memory 26.8 的 graph-aware 方案有代码可跑,做 RAG 的可以试试。
单纯按语义相似度检索在事实间存在关系时会失效,比如两条记录分别写着会议在 Monday 和已改到 Tuesday,flat 检索会同时返回但无法判断哪条有效。graph-aware 检索把事实存为持久记忆记录,用带标签的有向边(如 supersedes、supports、contradicts)连接,再沿边扩展搜索结果,返回匹配事实及其关系。Oracle AI Agent Memory 26.8 已实现 graph-aware search,官方提供了技术 walkthrough 和代码。
Searching data using semantic similarity alone is flawed. Graph-aware retrieval is the way to go.
The basic implementation runs flat retrieval to select records that match a query. This ranks records by semantic similarity and returns the closest matches from the store.
This works well when you store the information you need in independent records, but it fails when you need to understand relationships between facts.
Graph-aware retrieval is a huge upgrade.
It has three components:
1. It stores facts as persistent memory records
2. It connects records with directed links labeled with their relationships. For example, "supersedes," "supports," or "contradicts"
3. It expands search results by going through the links and returning every connected record
Because of this, your query results will contain both matching facts and information about their relationships.
Imagine you have two stored conversations:
• "The meeting is on Monday." • "The meeting has moved to Tuesday."
If you use a simple flat search to answer, "When is the meeting?", you'll get both records back because they match the question.
If you use graph-aware retrieval, you will get back a "superseeds" relationship showing that Tuesday replaces Monday.
Oracle AI Agent Memory 26.8 implements graph-aware search. You can read their technical walkthrough and check out the code here:
https://t.co/7gQIbQN1GT
Thanks to the @OracleDevs team for partnering with me on this post.