分叉了 CozoDB,以赋予智能体认知原语。

1作者: shanrizvi3 天前原帖
CozoDB 是由 Ziyang Hu 和 Cozo 项目作者创建的嵌入式关系图向量数据库。它在一个嵌入式引擎中实现了 Datalog、向量搜索(HNSW)和全文搜索,旨在成为“人工智能的海马体”。不幸的是,该项目在 2024 年 12 月后沉寂下来。KuzuDB 是另一个类似于 Cozo 的嵌入式图数据库,具有向量和全文索引,于 2025 年 10 月被归档。 我决定继续这一愿景,利用 Cozo 构建一个受神经科学启发的记忆和推理基础,采用认知本体论。它涵盖事件、认知结构、意图和行动,并支持多代理。使用您选择的大型语言模型(LLM)从文档和会话记录中提取信息的提取管道,去重并检测跨文档矛盾。所有内容都有版本控制,并追溯到源数据块,支持时间旅行。 但我们最依赖的功能需要改进,因此我在相同的 MPL-2.0 许可证下对 Cozo 进行了硬分叉,命名为 MnesticDB,并进行了改进。 我将一个包含 40,000 个数据块的语料库的索引构建时间从 89 秒减少到 8 秒,使用真实的 384 维嵌入,且没有影响召回率,通过平行重建 HNSW 索引,而不是逐行构建。 在索引重建期间,我解除对读取的阻塞,之前构建一个 151,000 个索引、1536 维的索引需要超过一个小时;现在它可以在不锁定的情况下构建,在一次测试中,40,000 向量索引在 6 秒内构建完成,同时支持 90,000 次并发读取。 我增加了跨语义(HNSW)、关键词(BM25)和图形接近信号的互惠排名融合,速度约为 42 毫秒,比单独运行的三条查询快 4 倍。 在将默认的全文评分器从 tf-idf 切换到 Okapi BM25 后,融合召回率在 40,000 个数据块的语料库上从 0.75 提升至 0.954,接近 DuckDB 的 0.957。 MnesticDB: https://www.mnesticdb.com https://www.github.com/shuruheel/mnestic 回到记忆和推理基础,我增加了对结构化数据的支持,允许用户连接 Postgres 数据库,从模式草拟操作本体,并将行同步为类型化图节点,具有来源和按需实时字段,融合到提取的认知本体中。这使得代理能够通过一个接口查询业务表和从文档中提炼的知识,同时显示矛盾和历史。 MindGraph: https://mindgraph.cloud/ https://www.github.com/shuruheel/mindgraph-rs 在 LongMemEval 的 60 个问题分层试点中,我们得分 87%,没有检索错误,强大的事实召回率(100%)和强大的时间推理(90%)。遗漏主要集中在偏好问题(70%),我随后进行了修复,但尚未重新运行基准测试。计划是最终运行完整的 500 个问题的测试,因为目前样本量的置信区间相当宽。 我一直在独自构建这个项目,这并不是最佳选择,因此如果您对此感兴趣,请考虑成为 MnesticDB 项目的贡献者,或成为 MindGraph(代理的认知图基础)的共同创始人。 在这里问我任何问题,或发送电子邮件至 shan@rizvi.nu。
查看原文
CozoDB is an embedded relational-graph-vector database created by Ziyang Hu and the Cozo Project authors. It does Datalog, vector search (HNSW), and full-text search in a single embedded engine and was created with the vision to be the “Hippocampus for AI”. Unfortunately, the project went quiet after December 2024. KuzuDB, another embedded graph database with vector and full-text indexes similar to Cozo, was archived in October 2025.<p>I decided to continue the vision by using Cozo to build a memory and reasoning substrate with a cognitive ontology inspired by neuroscience. It covers events, epistemic structure, intent, and action, with multi-agent support. An extraction pipeline using an LLM of your choice to extract these from documents and session transcripts, deduplicates them, and detects cross-document contradictions. Everything is versioned and provenanced back to source chunks, with time travel.<p>But the features we rely on most needed work, so I hard-forked Cozo as MnesticDB under the same MPL-2.0 license, and made improvements.<p>I reduced index build time from 89s to 8s on a 40,000 chunk corpus with real 384-dimension embeddings without affecting recall by rebuilding the HNSW index flat-and-parallel rather than row-by-row.<p>I unblocked reads during index rebuilds, which would take more than an hour for a 151,000 index with 1536 dimensions; it now builds off-lock, with a 40,000 vector index building under 6 seconds with 90,000 concurrent reads in one test.<p>I added reciprocal-rank fusion across semantic (HNSW), keyword (BM25), and graph proximity signals at around 42ms, 4x faster than the three queries running separately.<p>After switching the default full-text scorer from tf-idf to Okapi BM25, fused recall improved from 0.75 to 0.954 on a 40,000 chunk corpus, on par with DuckDB’s 0.957.<p>MnesticDB: https:&#x2F;&#x2F;www.mnesticdb.com https:&#x2F;&#x2F;www.github.com&#x2F;shuruheel&#x2F;mnestic<p>Returning to the memory and reasoning substrate, I added support for structured data, allowing users to connect a Postgres database, draft an operational ontology from the schema, and sync rows in as typed graph nodes, with provenance and on-demand live fields, fused into the same graph extracted as the cognitive ontology. This allows an agent to query business tables and knowledge distilled from documents through one interface, with contradictions and history on both.<p>MindGraph: https:&#x2F;&#x2F;mindgraph.cloud&#x2F; https:&#x2F;&#x2F;www.github.com&#x2F;shuruheel&#x2F;mindgraph-rs<p>In a 60-question stratified pilot of LongMemEval, we scored 87% with zero retrieval errors, strong factual recall (100%), and strong temporal reasoning (90%). The misses clustered in preference questions (70%), which I subsequently fixed, but haven’t re-run the benchmark yet. The plan is to eventually run the full 500-question run as the confidence interval is quite wide at the current sample size.<p>I’ve been building this solo, which is not optimal, so if this piques your interest, please consider becoming a contributor to the MnesticDB project, or a co-founder of MindGraph (the cognitive graph substrate for agents).<p>Ask me anything here, or email shan@rizvi.nu.