Neogenesis System 是一个基于元认知理论构建的先进AI决策框架。它超越了传统的"问题-答案"模式,赋予AI一种**"思考如何思考"**的能力。通过一系列架构创新,本系统使AI能够在决策的思考阶段就进行实时的自我验证、学习和进化,从而像人类专家一样,在复杂和不确定的环境中做出高质量的决策。
- 🧠 元认知突破:AI不仅会思考问题,更会思考"如何思考"
- 🔬 即时学习:在思考阶段就获得反馈,告别传统"执行后才能学习"的局限
- 💡 创新突破:独创的Aha-Moment机制,让AI在困境中迸发创意
- 🏆 智慧沉淀:黄金模板系统,将成功经验固化为可复用的智慧
- 🌐 实时增强:RAG技术融合,基于最新信息做出明智决策
很多用户会问:这是一个AI框架还是一个Agent框架?
答案是:Neogenesis System 是一个为智能体(Agent)构建"认知内核"的高级框架。
本项目不关注底层模型训练,而是聚焦于如何组织和调度预训练好的大语言模型(LLM)来完成复杂的认知任务。
传统的Agent框架更侧重于工具调用、任务编排和与外部环境交互的"行动循环"。Neogenesis 则专注于Agent在做出具体行动之前的"内在思考循环"——即如何进行高质量的规划、推理、反思和决策。
您可以将 Neogenesis 视为构建复杂决策智能体(Complex Decision-Making Agent)的"大脑"或"操作系统"。它为Agent提供了一个强大、透明且能够通过经验自我进化的思考引擎。
flowchart LR
A[外部任务输入] --> B[Neogenesis认知内核]
B --> C[高质量决策输出]
B --> D[传统Agent框架]
D --> E[工具调用与<br>环境交互]
E --> F[任务执行结果]
F --> B
style B fill:#e3f2fd,stroke:#1976d2,stroke-width:3px,stroke:#000000,color:#000000,font-weight:bold
style D fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,stroke:#000000,color:#000000,font-weight:bold
Neogenesis System 的核心价值在于其独特的架构设计,它将决策过程从一个线性的黑箱转变为一个透明、可迭代、且能够自我优化的元认知循环。
我们摒弃了传统的"思考→执行→学习"模型,首创了在思考阶段即可学习的闭环流程。这使得AI能在投入实际成本前,就预判并规避错误的思考路径,极大提升了决策的质量和效率。
flowchart LR
subgraph Thinking_Process["AI 思考过程"]
A["阶段一: 思维种子生成 - RAG-Enhanced Seed Generation"] --> B{"阶段二: 种子方向验证 - Initial Feasibility Check"}
B -->|通过验证| C["阶段三: 多路径思维展开 - Diverse Path Generation"]
B -->|未通过| A
C --> D["阶段四: 路径验证与即时学习 - Path Validation & Instant Learning"]
D --> E["阶段五: 智慧决策诞生 - Meta-MAB Final Decision"]
end
subgraph Real_time_Learning_Loop["实时学习循环"]
D -- 验证结果反馈 --> F((MAB知识库更新))
F -- 权重优化 --> E
E -- 决策结果 --> G["执行与环境交互"]
G -- 执行反馈 --> F
end
style A fill:#e3f2fd,stroke:#000000,color:#000000,font-weight:bold
style B fill:#ffcdd2,stroke:#000000,color:#000000,font-weight:bold
style C fill:#e0f7fa,stroke:#000000,color:#000000,font-weight:bold
style D fill:#fff9c4,stroke:#000000,color:#000000,font-weight:bold
style E fill:#e8f5e9,stroke:#000000,color:#000000,font-weight:bold
style F fill:#ffecb3,stroke:#000000,color:#000000,font-weight:bold
style G fill:#f3e5f5,stroke:#000000,color:#000000,font-weight:bold
专业价值: 这种"思考即学习"的模式,使AI具备了前所未有的反思和预演能力。它模拟了人类专家在制定方案时,会反复在头脑中推演、评估不同方案可行性的过程,从而在早期阶段就淘汰劣质思路,聚焦于高潜力方向。
系统的心脏是一个经过深度改造的MAB学习引擎,它不仅是选择器,更是策略的生成器和管理者。
创新点: 系统能自动识别并"固化"在特定场景下持续成功的思维路径 (Reasoning Path),将其提升为"黄金模板"。当未来遇到相似问题时,系统会优先调用这些模板,实现知识的高效复用。
专业价值: 这是一种经验驱动的决策加速机制。它使AI能够从过去的成功中学习,形成自己的"决策直觉",在保证质量的同时大幅缩短思考时间。
创新点: MAB收敛器 (MABConverger) 能够根据当前所有思维路径的"收敛"情况,动态选择最合适的MAB算法(如探索性强的Thompson Sampling或利用性强的Epsilon-Greedy)。
专业价值: 实现了探索(尝试新思路)与利用(使用已知最优解)的智能平衡,确保系统既不会陷入局部最优,也不会无休止地进行低效探索。
当系统面临以下困境时,将触发此机制:
- 所有常规思维路径的置信度都低于阈值
- 系统决策连续多次失败
- 所有路径在实时验证阶段均被判定为不可行
创新点: 触发后,系统会启动creative_bypass(创造性绕道)模式,强制PathGenerator生成一批非常规、高创新性的思维路径,并将其注入决策池,从而打破思维僵局。
专业价值: 模拟了人类专家在遇到瓶颈时的**"灵感迸发"**。它为AI提供了一种跳出常规思维框架、进行非线性思考的能力,是解决高度复杂和创新性问题的关键。
系统的决策起点和验证过程都深度整合了检索增强生成(RAG)技术。
创新点:
- RAG种子生成: RAGSeedGenerator在生成最初的"思维种子"时,会先智能分析问题,形成搜索策略,然后通过search_client获取互联网上的实时、相关信息,最后综合这些信息生成一个基于事实的、上下文丰富的思考起点。
- RAG实时验证: 在决策流程的第二和第四阶段,MainController会调用verify_idea_feasibility方法,利用搜索引擎验证"思维种子"和每一条"思维路径"的现实可行性,并将验证结果作为即时反馈提供给MAB系统。
专业价值: RAG的整合确保了AI的思考**"脚踏实地"**,其决策不仅基于模型内部的知识,更与当前世界的最新信息保持同步。这极大地提升了决策的时效性、准确性和可靠性。
Neogenesis System 采用高度模块化和可扩展的架构设计,各组件职责清晰,通过依赖注入的方式协同工作。
graph TD
subgraph "展示与交互层"
UI["演示与交互界面"]
end
subgraph "核心控制层"
MC["主控制器 - 五阶段流程协调"]
end
subgraph "LangChain 集成层"
LC_AD["LangChain 适配器 - LangChain 兼容性"]
LC_PS["持久化存储 - 多后端存储"]
LC_SM["状态管理 - ACID 事务"]
LC_DS["分布式状态 - 多节点同步"]
LC_AC["高级链 - 链工作流"]
LC_EE["执行引擎 - 并行处理"]
LC_CO["协调器 - 链协调"]
LC_TO["LangChain 工具 - 扩展工具库"]
end
subgraph "决策逻辑层"
PR["先验推理器 - 快速启发式分析"]
RAG["RAG种子生成器 - RAG增强思维种子"]
PG["路径生成器 - 多路径思维生成"]
MAB["MAB收敛器 - Meta-MAB与学习"]
end
subgraph "工具抽象层"
TR["工具注册表 - 统一工具管理"]
WST["网络搜索工具"]
IVT["想法验证工具"]
end
subgraph "工具与服务层"
LLM["LLM管理器 - 多LLM提供管理"]
SC["搜索客户端 - 网页搜索与验证"]
PO["性能优化器 - 并行与缓存"]
CFG["配置 - 主/演示配置"]
end
subgraph "存储后端"
FS["文件系统 - 版本化存储"]
SQL["SQLite - ACID 数据库"]
LMDB["LMDB - 高性能KV存储"]
MEM["内存 - 内存缓存"]
REDIS["Redis - 分布式缓存"]
end
subgraph "LLM提供商层"
OAI["OpenAI - GPT-3.5/4/4o"]
ANT["Anthropic - Claude-3 系列"]
DS["DeepSeek - deepseek-chat/coder"]
OLL["Ollama - 本地模型"]
AZ["Azure OpenAI - 企业模型"]
end
UI --> MC
MC --> LC_AD
LC_AD --> LC_CO
LC_CO --> LC_AC
LC_CO --> LC_EE
LC_AC --> LC_SM
LC_SM --> LC_PS
LC_DS --> LC_SM
LC_PS --> FS
LC_PS --> SQL
LC_PS --> LMDB
LC_PS --> MEM
LC_PS --> REDIS
MC --> PR
MC --> RAG
MC --> PG
MC --> MAB
MC --> TR
MAB --> LC_SM
RAG --> TR
RAG --> LLM
PG --> LLM
MAB --> PG
MC --> PO
TR --> WST
TR --> IVT
TR --> LC_TO
WST --> SC
IVT --> SC
LLM --> OAI
LLM --> ANT
LLM --> DS
LLM --> OLL
LLM --> AZ
style LC_AD fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#000000,font-weight:bold
style LC_PS fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#000000,font-weight:bold
style LC_SM fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#000000,font-weight:bold
style LC_DS fill:#e8f5e8,stroke:#388e3c,stroke-width:2px,color:#000000,font-weight:bold
style UI fill:#bbdefb,stroke:#1976d2,stroke-width:2px,color:#000000,font-weight:bold
style MC fill:#c8e6c9,stroke:#388e3c,stroke-width:2px,color:#000000,font-weight:bold
style PR fill:#ffe0b2,stroke:#f57c00,stroke-width:2px,color:#000000,font-weight:bold
style RAG fill:#d1c4e9,stroke:#7b1fa2,stroke-width:2px,color:#000000,font-weight:bold
style PG fill:#b3e5fc,stroke:#0288d1,stroke-width:2px,color:#000000,font-weight:bold
style MAB fill:#c5e1a5,stroke:#689f38,stroke-width:2px,color:#000000,font-weight:bold
style TR fill:#fff9c4,stroke:#fbc02d,stroke-width:2px,color:#000000,font-weight:bold
style WST fill:#ffccbc,stroke:#d84315,stroke-width:2px,color:#000000,font-weight:bold
style IVT fill:#f0f4c3,stroke:#827717,stroke-width:2px,color:#000000,font-weight:bold
style LC_TO fill:#c5cae9,stroke:#3f51b5,stroke-width:2px,color:#000000,font-weight:bold
style LLM fill:#ffe0b2,stroke:#f57c00,stroke-width:2px,color:#000000,font-weight:bold
style SC fill:#d7ccc8,stroke:#5d4037,stroke-width:2px,color:#000000,font-weight:bold
style PO fill:#b2dfdb,stroke:#00796b,stroke-width:2px,color:#000000,font-weight:bold
style CFG fill:#f8bbd0,stroke:#c2185b,stroke-width:2px,color:#000000,font-weight:bold
style FS fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px,color:#000000,font-weight:bold
style SQL fill:#c5cae9,stroke:#303f9f,stroke-width:2px,color:#000000,font-weight:bold
style LMDB fill:#b2dfdb,stroke:#00796b,stroke-width:2px,color:#000000,font-weight:bold
style MEM fill:#fff9c4,stroke:#fbc02d,stroke-width:2px,color:#000000,font-weight:bold
style REDIS fill:#ffccbc,stroke:#d84315,stroke-width:2px,color:#000000,font-weight:bold
style OAI fill:#c8e6c9,stroke:#388e3c,stroke-width:2px,color:#000000,font-weight:bold
style ANT fill:#ffe0b2,stroke:#f57c00,stroke-width:2px,color:#000000,font-weight:bold
style DS fill:#d1c4e9,stroke:#7b1fa2,stroke-width:2px,color:#000000,font-weight:bold
style OLL fill:#b3e5fc,stroke:#0288d1,stroke-width:2px,color:#000000,font-weight:bold
style AZ fill:#c5e1a5,stroke:#689f38,stroke-width:2px,color:#000000,font-weight:bold
组件说明:
- MainController: 系统的总指挥,负责编排完整的五阶段决策流程
- RAGSeedGenerator / PriorReasoner: 决策的起点,负责生成高质量的"思维种子"
- PathGenerator: 系统的"发散思维"模块,基于种子生成多样化的解决方案
- MABConverger: 系统的"收敛思维"与"学习"模块,负责评估和选择,并从经验中学习
- 工具层: 提供了如强化API客户端、搜索引擎、性能优化器等可复用的底层能力
核心技术:
- 核心语言: Python 3.8+
- AI引擎: DeepSeek Chat API
- 核心算法: Meta Multi-Armed Bandit (Thompson Sampling, UCB, Epsilon-Greedy), Retrieval-Augmented Generation (RAG)
- 外部服务: DuckDuckGo Search
- 关键库: requests, numpy, duckduckgo-search
- Python 3.8 或更高版本
- pip 包管理器
- 克隆仓库
git clone https://github.com/your-repo/neogenesis-system.git
cd neogenesis-system- 安装依赖
# (推荐) 创建并激活虚拟环境
python -m venv venv
source venv/bin/activate # on Windows: venv\Scripts\activate
# 安装依赖包
pip install -r requirements.txt- 配置API密钥 (可选,但推荐)
在项目根目录下创建一个 .env 文件,并填入您的DeepSeek API密钥:
DEEPSEEK_API_KEY="your_deepseek_api_key"如果没有密钥,系统将以功能受限的模拟模式运行。
我们提供了多种演示模式,让您可以直观地感受AI的思考过程。
# 启动菜单,选择体验模式
python start_demo.py
# (推荐) 直接运行快速模拟演示,无需任何配置
python quick_demo.py
# 运行连接真实系统的完整交互式演示
python run_demo.pyimport os
from dotenv import load_dotenv
from meta_mab.controller import MainController
# 加载环境变量
load_dotenv()
# 初始化控制器
api_key = os.getenv("DEEPSEEK_API_KEY")
controller = MainController(api_key=api_key)
# 提出一个复杂问题
query = "为一家初创科技公司设计一套可扩展、低成本的云原生技术栈"
context = {"domain": "cloud_native_architecture", "company_stage": "seed"}
# 获取AI的决策
decision_result = controller.make_decision(user_query=query, execution_context=context)
# 查看最终选择的思考路径
chosen_path = decision_result.get('chosen_path')
if chosen_path:
print(f"🚀 AI选择的思考路径: {chosen_path.path_type}")
print(f"📝 核心思路: {chosen_path.description}")
# (可选) 提供执行结果反馈,帮助AI学习
controller.update_performance_feedback(
decision_result=decision_result,
execution_success=True,
execution_time=12.5,
user_satisfaction=0.9,
rl_reward=0.85
)
print("\n✅ AI已接收反馈并完成学习!")| 指标 | 表现 | 说明 |
|---|---|---|
| 🎯 决策准确率 | 85%+ | 基于历史验证数据 |
| ⚡ 平均响应时间 | 2-5秒 | 包含完整五阶段处理 |
| 🧠 路径生成成功率 | 95%+ | 多样化思维路径生成 |
| 🏆 黄金模板命中率 | 60%+ | 成功经验复用效率 |
| 💡 Aha-Moment触发率 | 15%+ | 创新突破场景占比 |
| 指标 | 表现 | 说明 |
|---|---|---|
| 🔧 工具集成成功率 | 92%+ | 工具增强验证的可靠性 |
| 🔍 工具发现准确率 | 88%+ | 为上下文选择正确工具的能力 |
| 🚀 工具增强决策质量提升 | +25% | 使用外部工具后决策质量的相对提升 |
| 🎯 混合选择准确率 | 94%+ | MAB+LLM 融合策略的精度 |
| 🧠 冷启动检测率 | 96%+ | 精确识别不熟悉工具/场景的能力 |
| ⚡ 经验模式效率 | +40% | 对熟悉工具的性能提升 |
| 🔍 探索模式成功率 | 89%+ | LLM 引导下工具发现的效果 |
| 📈 学习收敛速度 | 3-5 次 | MAB 优化的学习曲线 |
| 🤖 提供商可用性 | 99%+ | 多 LLM 提供商的冗余可用性 |
| 🔄 自动故障切换成功率 | 98%+ | 无缝切换提供商的成功率 |
# 运行所有测试
python -m pytest tests/
# 运行单元测试示例
python tests/examples/simple_test_example.py
# 运行性能测试
python tests/unit/test_performance.py# 验证MAB算法收敛性
python tests/unit/test_mab_converger.py
# 验证路径生成鲁棒性
python tests/unit/test_path_creation_robustness.py
# 验证RAG种子生成
python tests/unit/test_rag_seed_generator.py# 产品策略决策
result = controller.make_decision(
"如何为我们的SaaS产品制定下一季度的功能优先级?",
execution_context={
"industry": "software",
"stage": "growth",
"constraints": ["budget_limited", "team_capacity"]
}
)# 架构设计决策
result = controller.make_decision(
"设计一个支持千万级并发的实时推荐系统",
execution_context={
"domain": "system_architecture",
"scale": "large",
"requirements": ["real_time", "high_availability"]
}
)# 市场分析决策
result = controller.make_decision(
"分析AI工具市场的竞争格局和机会点",
execution_context={
"analysis_type": "market_research",
"time_horizon": "6_months",
"focus": ["opportunities", "threats"]
}
)# Tool-enhanced technical decisions with real-time information gathering
result = controller.make_decision(
"Should we adopt Kubernetes for our microservices architecture?",
execution_context={
"domain": "system_architecture",
"team_size": "10_engineers",
"current_stack": ["docker", "aws"],
"constraints": ["learning_curve", "migration_complexity"]
}
)
# The system automatically:
# 1. Uses WebSearchTool to gather latest Kubernetes trends and best practices
# 2. Applies IdeaVerificationTool to validate feasibility based on team constraints
# 3. Integrates real-time information into decision-making process
# 4. Provides evidence-based recommendations with source citations
print(f"Tool-enhanced decision: {result.get('chosen_path', {}).get('description', 'N/A')}")
print(f"Tools used: {result.get('tools_used', [])}")
print(f"Information sources: {result.get('verification_sources', [])}")# Check available providers and their status
status = controller.get_llm_provider_status()
print(f"Healthy providers: {status['healthy_providers']}")
# Switch to a specific provider for particular tasks
controller.switch_llm_provider("anthropic") # Use Claude for complex reasoning
result_reasoning = controller.make_decision("Complex philosophical analysis...")
controller.switch_llm_provider("deepseek") # Use DeepSeek for coding tasks
result_coding = controller.make_decision("Optimize this Python algorithm...")
controller.switch_llm_provider("openai") # Use GPT for general tasks
result_general = controller.make_decision("Business strategy planning...")
# Get cost and usage statistics
cost_summary = controller.get_llm_cost_summary()
print(f"Total cost: ${cost_summary['total_cost_usd']:.4f}")
print(f"Requests by provider: {cost_summary['cost_by_provider']}")
# Run health check on all providers
health_status = controller.run_llm_health_check()
print(f"Provider health: {health_status}")# Install core LangChain integration dependencies
pip install langchain langchain-community
# Install storage backend dependencies
pip install lmdb # For LMDB high-performance storage
pip install redis # For Redis distributed storage
pip install sqlalchemy # For enhanced SQL operations
# Install distributed coordination dependencies
pip install aioredis # For async Redis operations
pip install consul # For service discovery (optional)from neogenesis_system.langchain_integration import (
create_neogenesis_chain,
PersistentStateManager,
AdvancedChainComposer
)
# Create LangChain-compatible Neogenesis chain
neogenesis_chain = create_neogenesis_chain(
storage_backend="lmdb",
enable_distributed_state=True,
session_persistence=True
)
# Use as standard LangChain component
from langchain.chains import SequentialChain
# Integrate with existing LangChain workflows
full_workflow = SequentialChain(chains=[
preprocessing_chain, # Standard LangChain chain
neogenesis_chain, # Our intelligent decision engine
postprocessing_chain # Standard LangChain chain
])
# Execute with persistent state
result = full_workflow.run({
"input": "Design scalable microservices architecture",
"context": {"team_size": 15, "timeline": "6_months"}
})# Parallel & Distributed examples (see README_EN for full samples)
from neogenesis_system.langchain_integration.advanced_chains import AdvancedChainComposer
from neogenesis_system.langchain_integration.execution_engines import ParallelExecutionEngine
from neogenesis_system.langchain_integration.distributed_state import DistributedStateManager
from neogenesis_system.langchain_integration.coordinators import ClusterCoordinator
# Parallel execution engine
composer = AdvancedChainComposer()
execution_engine = ParallelExecutionEngine(max_workers=6)
# Distributed coordination
distributed_state = DistributedStateManager(
node_id="decision_node_1",
cluster_nodes=["node_1:8001", "node_2:8002", "node_3:8003"],
consensus_protocol="raft"
)
cluster_coordinator = ClusterCoordinator(
distributed_state=distributed_state,
load_balancing="intelligent"
)我们热烈欢迎社区的贡献!无论是Bug修复、功能建议还是代码提交,都将帮助Neogenesis System变得更好。
- 🐛 Bug报告:发现问题请提交Issue
- ✨ 功能建议:提出新功能想法
- 📝 文档改进:完善文档和示例
- 🔧 代码贡献:提交Pull Request
- 🔨 工具开发:为系统创建新的工具(实现 BaseTool 接口)
- 🧪 工具测试:参与工具集成测试与验证,确保工具与决策引擎的兼容性和稳定性
# 1. Fork并克隆项目
git clone https://github.com/your-username/neogenesis-system.git
# 2. 创建开发分支
git checkout -b feature/your-feature-name
# 3. 安装开发依赖
pip install -r requirements-dev.txt
# 4. 运行测试确保基线功能正常
python -m pytest tests/
# 5. 开发新功能...
# 6. 提交Pull Request请参考 CONTRIBUTING.md 获取详细指南。
本项目采用 MIT License 开源。详见 LICENSE 文件。
- DeepSeek AI:提供强大的大语言模型能力
- Multi-Armed Bandit理论:为智能决策提供算法基础
- RAG技术:实现知识增强的思维生成
- 元认知理论:启发了系统的整体架构设计
- 架构设计:Neogenesis Team
- 算法实现:MAB & RAG专家组
- 工程开发:Full-Stack开发团队
- 测试验证:QA & Research团队
- 📖 文档Wiki:docs/
- 💬 讨论社区:GitHub Discussions
- 🐛 问题反馈:GitHub Issues
- 📧 邮件联系:
- v1.1:增强RAG信息源,支持更多搜索引擎
- v1.2:多语言支持,国际化部署
- v1.3:可视化决策流程,Web界面
- v2.0:分布式部署,企业级集成