自称开源Palantir,为AI agent提供知识图谱+确定性推理+W3C PROV-O溯源层,使每个决策可审计,8200星,MIT协议。
"向量数据库告诉你'什么是相关的'。知识图谱告诉你'为什么它是相关的'。溯源层告诉你'这个结论从何而来'。"
这是"每日一个开源项目"系列第 157 篇。今天要介绍的项目是 Semantica——来自 semantica-agi 的图原生 AI 决策基础设施,自定位为"AI 智能体的开源 Palantir"。
一句话概括它的功能:让每一个 AI 智能体决策都可解释、可追溯、可审计。
它不是 RAG 框架,不是向量数据库,也不是智能体框架。它位于这三者之下,提供确定性推理层和溯源层。当一个智能体做出决策时,你可以精确查询它使用了哪些上下文数据、遵循了哪些推理步骤、应用了哪些策略,以及每条证据的来源。
8200 Stars。MIT 协议。Python 3.8+。
Semantica 的定位与 RAG、向量数据库的区别
决策作为一等公民:为什么 AI 决策不应仅仅是日志条目
确定性推理引擎:无需 LLM 的可解释推理
W3C PROV-O 溯源:每个事实的来源链
冲突检测与时间旅行
使用场景:金融合规、医疗、法律、网络安全
前置知识
对 AI 智能体和 LLM 的基本理解
熟悉向量数据库的作用
基本知识图谱概念(节点、边、三元组)
背景:AI 问责缺口
当前的 AI 智能体存在一个普遍问题:决策过程不透明。
智能体给出一个推荐。为什么?它使用了什么数据?那些数据从何而来?有没有被其他内容矛盾?这个推荐一个月后还能复现吗?
在低风险场景中,这可以接受。但在银行贷款审批、临床决策支持、法律合同分析或政府政策执行中,"AI 这么说的"是不够的。监管者要求完整的决策日志、数据溯源、推理证据和合规证明。
现有工具处理语义检索(向量数据库)和对话记忆(各种记忆解决方案),但没有东西解决以下问题:
决策历史:每个智能体决策的结构化记录
因果溯源:这个结论,来自这个数据,经过这个推理步骤
冲突处理:当新数据与旧数据矛盾时,是静默覆盖还是标记?
跨智能体共享上下文:多个智能体在一个智能层上工作,而非孤立烟囱
时间维度:在某一时刻知识状态是什么样的(时间旅行)?
Semantica 将这些问题全部作为一等公民来对待。
决策是图节点,不是日志条目
传统方法将 AI 操作记录为日志文件——时间戳 + 字符串。难以查询,几乎无法交叉引用。
Semantica 将每个 AI 决策建模为具有完整生命周期的完整图节点:
from semantica.context import AgentContext, record_decision
ctx = AgentContext(agent_id="loan-agent-01", session_id="session-xyz")
decision = record_decision(
context=ctx,
decision_type="loan_approval",
inputs={"applicant_id": "A123", "amount": 50000},
output={"approved": True, "confidence": 0.87},
reasoning_steps=[...],
policies_applied=["credit_policy_v3", "risk_limit_2024"],
provenance_sources=[...]
)
这个决策节点可以:
因果链接到其他决策("这个决策影响了那个决策")
检索历史先例("类似案例以前是如何处理的")
导出用于合规(为监管者生成审计报告)
确定性推理引擎
Semantica 的推理层使用经典 AI 确定性算法——无需 LLM:
Rete 网络:高效模式匹配规则引擎
Datalog:声明式逻辑查询
SPARQL:RDF 图标准查询语言
前向链:从已知事实增量推导新结论
from semantica.reasoning import ForwardChainReasoner
reasoner = ForwardChainReasoner()
# Rule: if X is a customer of Y and Y is a Bank, then X has an account at Y
reasoner.add_rule(
condition=["?x customer_of ?y", "?y type Bank"],
conclusion="?x has_account_at ?y"
)
results = reasoner.reason(facts=[
("Alice", "customer_of", "HSBC"),
("HSBC", "type", "Bank")
])
# → [("Alice", "has_account_at", "HSBC")]
推理链中的每一步中间过程都被保留。完整的推导追踪可以导出给审计人员。
W3C PROV-O 溯源
知识图谱中的每个事实都携带溯源元数据,遵循 W3C PROV-O 标准:
from semantica.provenance import ProvenanceTracker
tracker = ProvenanceTracker()
tracker.record(
entity="Alice",
attribute="credit_score",
value=750,
source="TransUnion API",
retrieved_at="2026-08-17T10:00:00Z",
agent="data-ingestion-agent",
confidence=0.99
)
provenance = tracker.get_provenance("Alice", "credit_score")
# → {source: "TransUnion API", retrieved_at: ..., agent: ..., confidence: ...}
在受监管环境中,这是"证明你的 AI 决策基于可信数据"的技术基础。
冲突检测——不静默覆盖
当两个数据源对同一事实持不同意见时,标准 RAG 会静默覆盖(新数据取代旧数据)或任意选择。Semantica 将此视为需要显式处理的问题:
from semantica.conflicts import ConflictResolver
resolver = ConflictResolver()
conflicts = resolver.detect(
entity="Alice",
attribute="annual_income",
values=[
{"value": 80000, "source": "Tax Bureau", "date": "2025-01"},
{"value": 120000, "source": "Bank Statement", "date": "2025-06"}
]
)
# → Conflict detected: value conflict (80000 vs 120000)
# → Resolution strategy: most_recent wins
支持的解决策略:最近优先、最高置信度、优先数据源、标记待人工审核。
知识图谱构建(semantica.kg)
from semantica.kg import KnowledgeGraph
kg = KnowledgeGraph(backend="neo4j") # or falkordb / oxigraph
kg.ingest_document("contract.pdf")
kg.ingest_web("https://example.com/news")
kg.ingest_database(conn="postgresql://...", table="customers")
# Graph analysis
centrality = kg.betweenness_centrality()
communities = kg.community_detection()
links = kg.link_prediction(entity="Alice")
语义抽取(semantica.semantic_extract)
from semantica.semantic_extract import SemanticExtractor
extractor = SemanticExtractor()
result = extractor.extract("Apple acquired Beats Electronics for $3 billion in 2014.")
# → entities: [Apple, Beats Electronics]
# → relations: [(Apple, acquired, Beats Electronics)]
# → events: [acquisition, 2014]
# → triples: [(Apple, acquisition_of, Beats Electronics, {amount: 3B, year: 2014})]
多源摄取(semantica.ingest)
支持的来源:PDF、Word、CSV、JSON、XML、Web URL(含 JS 渲染)、PostgreSQL、MySQL、MongoDB、Databricks、Snowflake、Kafka。
GraphRAG 原生分块(semantica.split)
from semantica.split import GraphRAGSplitter
splitter = GraphRAGSplitter()
chunks = splitter.split("contract.pdf", entity_aware=True)
# → chunk boundaries respect entity integrity
与其他方案的定位对比
Semantica 不取代向量数据库或 RAG——它在它们之下添加了确定性推理和问责层。
金融合规:记录每笔贷款决策的数据溯源、推理步骤和应用的信贷策略——满足监管审计要求。
临床决策支持:药物相互作用知识图谱,每条临床建议都附有证据溯源链。符合 HIPAA 导出规范。
法律合同分析:案例法推理,每条法律结论可追溯到具体先例和法规。
网络安全:IOC(入侵指标)关联图、攻击归因链、事件响应时间线。
AI/ML 平台团队:为多个智能体构建共享结构化上下文层——智能体在共享智能层上工作,而非孤立烟囱。
pip install semantica # core
pip install semantica[all] # everything
# specific backends
pip install semantica[graph-neo4j] # Neo4j
pip install semantica[tripletstore-oxigraph] # embedded RDF (no external service needed)
pip install semantica[vectorstore-qdrant] # Qdrant
pip install semantica[llm-litellm] # LLM support
pip install semantica[crewai] # CrewAI integration
pip install semantica[explorer] # visualization workbench
最简单的起步方式(嵌入式 Oxigraph,无需外部数据库):
pip install semantica[tripletstore-oxigraph]
git clone https://github.com/semantica-agi/semantica
cd semantica
docker-compose up -d
# Knowledge Explorer: http://localhost:3000
# REST API: http://localhost:8000
智能体框架集成
MCP 服务器(Claude Code、Claude Desktop 及任何 MCP 兼容客户端):
{
"mcpServers": {
"semantica": {
"command": "python",
"args": ["-m", "semantica.mcp.server"]
}
}
}
CrewAI 原生集成:
from semantica.integrations.crewai import SemanticalKGTool
tool = SemanticalKGTool(kg=my_knowledge_graph)
# Use directly as a CrewAI agent tool
支持的智能体框架:Agno、CrewAI(原生)、LangChain、LangGraph、LlamaIndex、AutoGen、OpenAI Agents SDK、Google ADK(通过 REST/MCP)。
GitHub: semantica-agi/semantica
Website: getsemantica.ai
Docs: docs.getsemantica.ai
Discord: discord.gg/sV34vps5hH
Twitter/X: @BuildSemantica
Semantica 解决的是 AI 企业部署中最难的问题之一:问责。
向量数据库解决"找相关内容"。RAG 解决"用相关内容回答问题"。但"这个答案如何得出的、什么数据支持了它、是否存在矛盾、如果出问题谁负责"——整个这一层在当前 AI 工具链中是一个空白。
Semantica 填补了这个空白。它不与 RAG 竞争——它位于 RAG 之下,为每个 AI 决策添加确定性推理链和溯源标签。在金融、医疗、法律等受监管行业,这一层是区分"内部实验"和"监管者可接受的 production 部署"的关键。
"AI 智能体的开源 Palantir"这一定位是准确的:Palantir 的核心价值是连接数据、分析和决策过程,让政府机构和金融机构的操作员能够解释他们的决策。Semantica 的目标是在 AI 智能体身上实现同样的问责可能——开源且可自托管。
探索 PrimeSkills——精心挑选的 AI 智能体和技能市场。每一个都经过真实企业工作流验证,去除炒作,只保留真正有效的部分。
欢迎访问我的首页了解更多有用见解和有趣产品。