🧠 NexusMind
╔══════════════════════════════════════╗
║ ║
║ 🧠 NexusMind 🧠 ║
║ ║
║ Intelligent Scientific ║
║ Reasoning through ║
║ Graph-of-Thoughts ║
║ ║
╚══════════════════════════════════════╝通过思维图形进行智能科学推理
](https://github.com/SaptaDey/NexusMind/releases)   ](Dockerfile)   
🚀 Next-Generation AI Reasoning Framework for Scientific Research
Leveraging graph structures to transform how AI systems approach scientific reasoning
🔍 概述
NexusMind利用 图形结构 进行复杂的科学推理。它实现了 模型上下文协议(MCP) 与Claude Desktop等人工智能应用程序集成,提供专为复杂研究任务设计的高级科学推理思维图(ASR GoT)框架。
主要亮点:
- 使用基于图的推理处理复杂的科学查询
- 多维评估的动态置信度评分
- 采用现代Python和FastAPI构建,实现高性能
- Docker化,易于部署
- 模块化设计,可扩展性和定制化
- 通过MCP协议与Claude Desktop集成
🌟 主要特点
8阶段推理流程
graph TD
A[🌱 Stage 1: Initialization] --> B[🧩 Stage 2: Decomposition]
B --> C[🔬 Stage 3: Hypothesis/Planning]
C --> D[📊 Stage 4: Evidence Integration]
D --> E[✂️ Stage 5: Pruning/Merging]
E --> F[🔍 Stage 6: Subgraph Extraction]
F --> G[📝 Stage 7: Composition]
G --> H[🤔 Stage 8: Reflection]
A1[Create root node
Set initial confidence
Define graph structure] --> A
B1[Break into dimensions
Identify components
Create dimensional nodes] --> B
C1[Generate hypotheses
Create reasoning strategy
Set falsification criteria] --> C
D1[Gather evidence
Link to hypotheses
Update confidence scores] --> D
E1[Remove low-value elements
Consolidate similar nodes
Optimize structure] --> E
F1[Identify relevant portions
Focus on high-value paths
Create targeted subgraphs] --> F
G1[Synthesize findings
Create coherent insights
Generate comprehensive answer] --> G
H1[Evaluate reasoning quality
Identify improvements
Final confidence assessment] --> H
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
style D fill:#fff3e0
style E fill:#ffebee
style F fill:#f1f8e9
style G fill:#e3f2fd
style H fill:#fce4ec核心推理过程遵循一个复杂的8阶段流程:
- 🌱 初始化
- 使用多维置信向量从查询创建根节点 - 使用适当的元数据建立初始图形结构 - 在经验、理论、方法和共识维度上设定基线置信度
- 🧩 分解
- 将查询分解为关键维度:范围、目标、约束、数据需求、用例 - 从一开始就识别潜在的偏见和知识差距 - 创建具有初始置信度评估的维度节点
- 🔬 假设/规划
- 根据明确的证伪标准,每个维度生成3-5个假设 - 为每个假设制定详细的执行计划 - 带有学科来源和影响估计的标签
- 📊 证据整合
- 基于置信度成本比和影响迭代选择假设 - 使用类型化边缘(因果、时间、相关)收集和链接证据 - 使用贝叶斯方法和统计功率评估更新置信向量
- ✂️ 修剪/合并
- 删除置信度和影响分数低的节点 - 整合语义上相似的节点 - 优化图形结构,同时保留关键关系
- 🔍 子图提取
- 基于多个标准识别高价值子图 - 关注具有高置信度和影响力得分的节点 - 提取与原始查询相关的模式
- 📝 构图
- 将研究结果综合成连贯的叙述 - 用节点ID和边类型注释声明 - 提供全面的答案,并附有适当的引用
- 🤔 反思
- 执行全面的质量审核 - 评估覆盖率、偏差检测和方法学严谨性 - 提供最终的信心评估和改进建议
先进的技术能力
🔄 Multi-Dimensional Confidence 🧠 Graph-Based Knowledge 🔌 MCP Integration ⚡ FastAPI Backend
🐳 Docker Deployment 🧩 Modular Design ⚙️ Configuration Management 🔒 Type Safety
🌐 Interdisciplinary Bridge Nodes 🔗 Hyperedge Support 📊 Statistical Power Analysis 🎯 Impact Estimation
核心特点:
- 🧠 图形知识表示:用途
networkx用超节点和多层网络对复杂关系进行建模 - 🔄 动态置信向量:四维置信度评估(经验支持、理论基础、方法严谨性、共识一致性)
- 🌐 跨学科桥梁节点:自动连接不同研究领域的见解
- 🔗 高级边缘类型:支持因果关系、时间关系、相关关系和自定义关系类型
- 📊 统计严谨:综合功率分析和效应大小估计
- 🎯 影响驱动的优先级:专注于高影响力的研究方向
- 🔌 MCP服务器:与模型上下文协议无缝集成Claude桌面
- ⚡ 高性能API:具有异步支持的现代FastAPI实现
🛠️ 技术栈
Python 3.13+
FastAPI
NetworkX
Docker
Pytest
Pydantic
Poetry
Uvicorn
📂 项目结构
NexusMind/
├── 📁 config/ # Configuration files
│ ├── settings.yaml # Application settings
│ ├── claude_mcp_config.json # Claude MCP integration config
│ └── logging.yaml # Logging configuration
│
├── 📁 src/asr_got_reimagined/ # Main source code
│ ├── 📁 api/ # API layer
│ │ ├── 📁 routes/ # API route definitions
│ │ │ ├── mcp.py # MCP protocol endpoints
│ │ │ ├── health.py # Health check endpoints
│ │ │ └── graph.py # Graph query endpoints
│ │ ├── schemas.py # API request/response schemas
│ │ └── middleware.py # API middleware
│ │
│ ├── 📁 domain/ # Core business logic
│ │ ├── 📁 models/ # Domain models
│ │ │ ├── common.py # Common types and enums
│ │ │ ├── graph_elements.py # Node, Edge, Hyperedge models
│ │ │ ├── graph_state.py # Graph state management
│ │ │ ├── confidence.py # Confidence vector models
│ │ │ └── metadata.py # Metadata schemas
│ │ │
│ │ ├── 📁 services/ # Business services
│ │ │ ├── got_processor.py # Main GoT processing service
│ │ │ ├── evidence_service.py # Evidence gathering and assessment
│ │ │ ├── confidence_service.py # Confidence calculation service
│ │ │ ├── graph_service.py # Graph manipulation service
│ │ │ └── mcp_service.py # MCP protocol service
│ │ │
│ │ ├── 📁 stages/ # 8-Stage pipeline implementation
│ │ │ ├── base_stage.py # Abstract base stage
│ │ │ ├── stage_1_initialization.py # Stage 1: Graph initialization
│ │ │ ├── stage_2_decomposition.py # Stage 2: Query decomposition
│ │ │ ├── stage_3_hypothesis.py # Stage 3: Hypothesis generation
│ │ │ ├── stage_4_evidence.py # Stage 4: Evidence integration
│ │ │ ├── stage_5_pruning.py # Stage 5: Pruning and merging
│ │ │ ├── stage_6_extraction.py # Stage 6: Subgraph extraction
│ │ │ ├── stage_7_composition.py # Stage 7: Answer composition
│ │ │ └── stage_8_reflection.py # Stage 8: Quality reflection
│ │ │
│ │ └── 📁 utils/ # Utility functions
│ │ ├── graph_utils.py # Graph manipulation utilities
│ │ ├── confidence_utils.py # Confidence calculation utilities
│ │ ├── statistical_utils.py # Statistical analysis utilities
│ │ ├── bias_detection.py # Bias detection algorithms
│ │ └── temporal_analysis.py # Temporal pattern analysis
│ │
│ ├── 📁 infrastructure/ # Infrastructure layer
│ │ ├── 📁 database/ # Database integration
│ │ ├── 📁 cache/ # Caching layer
│ │ └── 📁 external/ # External service integrations
│ │
│ ├── main.py # Application entry point
│ └── app_setup.py # Application setup and configuration
│
├── 📁 tests/ # Test suite
│ ├── 📁 unit/ # Unit tests
│ │ ├── 📁 stages/ # Stage-specific tests
│ │ ├── 📁 services/ # Service tests
│ │ └── 📁 models/ # Model tests
│ ├── 📁 integration/ # Integration tests
│ └── 📁 fixtures/ # Test fixtures and data
│
├── 📁 scripts/ # Utility scripts
│ ├── setup_dev.py # Development setup
│ ├── add_type_hints.py # Type hint utilities
│ └── deployment/ # Deployment scripts
│
├── 📁 docs/ # Documentation
│ ├── api/ # API documentation
│ ├── architecture/ # Architecture diagrams
│ └── examples/ # Usage examples
│
├── 📁 static/ # Static assets
│ └── nexusmind-logo.png # Application logo
│
├── 📄 Docker Files & Config
├── Dockerfile # Docker container definition
├── docker-compose.yml # Multi-container setup
├── .dockerignore # Docker ignore patterns
│
├── 📄 Configuration Files
├── pyproject.toml # Python project configuration
├── poetry.lock # Dependency lock file
├── mypy.ini # Type checking configuration
├── pyrightconfig.json # Python type checker config
├── .pre-commit-config.yaml # Pre-commit hooks
├── .gitignore # Git ignore patterns
│
└── 📄 Documentation
├── README.md # This file
├── CHANGELOG.md # Version history
├── LICENSE # Apache 2.0 license
└── CONTRIBUTING.md # Contribution guidelines🚀 入门指南
先决条件
安装和设置(本地开发)
- 克隆存储库:
git clone https://github.com/SaptaDey/NexusMind.git
cd NexusMind- 使用Poetry安装依赖项:
poetry install这将创建一个虚拟环境,并安装中指定的所有必要软件包 pyproject.toml.
- 激活虚拟环境:
poetry shell- 配置应用程序:
# Copy example configuration
cp config/settings.example.yaml config/settings.yaml
# Edit configuration as needed
vim config/settings.yaml- 设置环境变量 (可选):
# Create .env file for sensitive configuration
echo "LOG_LEVEL=DEBUG" > .env
echo "API_HOST=0.0.0.0" >> .env
echo "API_PORT=8000" >> .env- 运行开发服务器:
python src/asr_got_reimagined/main.py或者,为了获得更多控制:
uvicorn asr_got_reimagined.main:app --reload --host 0.0.0.0 --port 8000API将于 http://localhost:8000.
Docker部署
graph TB
subgraph "Development Environment"
A[👨💻 Developer] --> B[🐳 Docker Compose]
end
subgraph "Container Orchestration"
B --> C[📦 NexusMind Container]
B --> D[📊 Monitoring Container]
B --> E[🗄️ Database Container]
end
subgraph "NexusMind Application"
C --> F[⚡ FastAPI Server]
F --> G[🧠 ASR-GoT Engine]
F --> H[🔌 MCP Protocol]
end
subgraph "External Integrations"
H --> I[🤖 Claude Desktop]
H --> J[🔗 Other AI Clients]
end
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
style F fill:#fff3e0
style G fill:#ffebee
style H fill:#f1f8e9- Docker Compose快速入门:
# Build and run all services
docker-compose up --build
# For detached mode (background)
docker-compose up --build -d
# View logs
docker-compose logs -f nexusmind- 单个Docker容器:
# Build the image
docker build -t nexusmind:latest .
# Run the container
docker run -p 8000:8000 -v $(pwd)/config:/app/config nexusmind:latest- 生产部署:
# Use production compose file
docker-compose -f docker-compose.prod.yml up --build -d- 访问服务:
- API文档: http://localhost:8000/docs - 健康检查: http://localhost:8000/health - MCP端点: http://localhost:8000/mcp
🔌 API终点
核心终点
- MCP协议:
POST /mcp
{
"method": "process_query",
"params": {
"query": "Analyze the relationship between microbiome diversity and cancer progression",
"confidence_threshold": 0.7,
"max_stages": 8
}
}- 健康检查:
GET /health
{
"status": "healthy",
"version": "0.1.0",
"timestamp": "2024-05-23T10:30:00Z"
}高级端点
- 图形查询:
POST /api/v1/graph/query
{
"query": "Research question or hypothesis",
"parameters": {
"disciplines": ["immunology", "oncology"],
"confidence_threshold": 0.6,
"include_temporal_analysis": true,
"enable_bias_detection": true
}
}- 图形状态:
GET /api/v1/graph/{session_id}
- 检索推理图的当前状态 - 包括置信度得分、节点关系和元数据
- 分析:
GET /api/v1/analytics/{session_id}
- 获取关于推理过程的全面指标 - 包括性能统计数据、信心趋势和质量指标
- 子图提取:
POST /api/v1/graph/{session_id}/extract
{
"criteria": {
"min_confidence": 0.7,
"node_types": ["hypothesis", "evidence"],
"include_causal_chains": true
}
}🧪 测试和质量保证
🧪 Testing 🔍 Type Checking ✨ Linting 📊 Coverage
poetry run pytest
poetry run pytest -v
poetry run mypy src/
pyright src/
poetry run ruff check .
poetry run ruff format .
poetry run pytest --cov=src
coverage html
开发命令
# Run full test suite with coverage
poetry run pytest --cov=src --cov-report=html --cov-report=term
# Run specific test categories
poetry run pytest tests/unit/stages/ # Stage-specific tests
poetry run pytest tests/integration/ # Integration tests
poetry run pytest -k "test_confidence" # Tests matching pattern
# Type checking and linting
poetry run mypy src/ --strict # Strict type checking
poetry run ruff check . --fix # Auto-fix linting issues
poetry run ruff format . # Format code
# Pre-commit hooks (recommended)
poetry run pre-commit install # Install hooks
poetry run pre-commit run --all-files # Run all hooks质量指标
- 类型安全:
- 具有严格mypy配置的全类型代码库 - 配置为 mypy.ini 和 pyrightconfig.json - 修复记录器类型问题: python scripts/add_type_hints.py
- 代码质量:
- 95%以上的测试覆盖率目标 - 使用Ruff自动格式化 - 预提交挂钩可实现一致的代码质量 - 8级管道综合集成测试
🔧 配置
应用程序设置(config/settings.yaml)
# Core application settings
app:
name: "NexusMind"
version: "0.1.0"
debug: false
log_level: "INFO"
# API configuration
api:
host: "0.0.0.0"
port: 8000
cors_origins: ["*"]
# ASR-GoT Framework settings
asr_got:
max_stages: 8
default_confidence_threshold: 0.6
enable_bias_detection: true
enable_temporal_analysis: true
max_hypotheses_per_dimension: 5
# Graph settings
graph:
max_nodes: 10000
enable_hyperedges: true
enable_multi_layer: true
temporal_decay_factor: 0.1MCP配置(config/claude_mcp_config.json)
{
"name": "nexusmind",
"description": "Advanced Scientific Reasoning with Graph-of-Thoughts",
"version": "0.1.0",
"endpoints": {
"mcp": "http://localhost:8000/mcp"
},
"capabilities": [
"scientific_reasoning",
"graph_analysis",
"confidence_assessment",
"bias_detection"
]
}🤝 贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详情。
开发设置
- 分叉存储库
- 创建要素分支:
git checkout -b feature/amazing-feature - 安装开发依赖项:
poetry install --with dev - 进行更改并添加测试
- 运行测试套件:
poetry run pytest - 提交拉取请求
代码的风格
- 遵循PEP 8风格指南
- 对所有函数和方法使用类型提示
- 编写全面的文档字符串
- 保持测试覆盖率在95%以上
📚 文档
📄 许可证
此项目根据Apache许可证2.0获得许可-请参阅 许可证 文件以获取详细信息。
🙏 致谢
- 网络X 图形分析能力社区
- 快速API 优秀web框架团队
- 派丹蒂克 用于稳健的数据验证
- 科研界寻求灵感和反馈
______________________________________________________________________
Built with ❤️ for the scientific research community
NexusMind - Advancing scientific reasoning through intelligent graph structures
