mcpField
F
flow-nexus-neural

flow-nexus-neural

github.com/ruvnet数据与数据库80.0k1.1k 次安装今天更新
代码仓库

关于 flow-nexus-neural

flow-nexus-neural 是用于在分布式 E2B 沙箱环境中训练、部署和管理神经网络的技能,支持自定义架构、市场模板、推理以及分布式或联邦训练。

主要功能

  1. 01训练多种神经网络架构
  2. 02对已训练模型运行预测
  3. 03浏览和部署市场模板
  4. 04管理分布式训练集群
  5. 05对模型进行基准测试和验证
  6. 06将模型发布为模板

适用场景

  1. 01训练 LSTM 模型进行时间序列预测
  2. 02部署情感分析模板
  3. 03在分布式节点上训练
  4. 04数据保留在本地节点的联邦训练

MCP 相关

该技能通过 Flow Nexus MCP 服务向 MCP 客户端提供神经网络训练、推理、模型管理、集群操作和市场功能。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/ruvnet/ruflo --skill flow-nexus-neural

安装后在 Claude Code 中输入/flow-nexus-neural确认已加载。

详细介绍

Flow Nexus 神经网络

在分布式 E2B 沙盒环境中部署、训练和管理神经网络。使用多种架构(前馈网络、LSTM、GAN、transformer)训练自定义模型,或使用市场中的预构建模板。

前提条件

# Add Flow Nexus MCP server
claude mcp add flow-nexus npx flow-nexus@latest mcp start

# Register and login
npx flow-nexus@latest register
npx flow-nexus@latest login

核心功能

1. 单节点神经网络训练

使用自定义架构和配置训练神经网络。

可用架构:

  • feedforward - 标准全连接网络
  • lstm - 用于序列的长短期记忆网络
  • gan - 生成对抗网络
  • autoencoder - 降维
  • transformer - 基于注意力机制的模型

训练级别:

  • nano - 最少资源(速度快,能力有限)
  • mini - 小型模型
  • small - 标准模型
  • medium - 复杂模型
  • large - 大规模训练
示例:训练自定义分类器
mcp__flow-nexus__neural_train({
  config: {
    architecture: {
      type: "feedforward",
      layers: [
        { type: "dense", units: 256, activation: "relu" },
        { type: "dropout", rate: 0.3 },
        { type: "dense", units: 128, activation: "relu" },
        { type: "dropout", rate: 0.2 },
        { type: "dense", units: 64, activation: "relu" },
        { type: "dense", units: 10, activation: "softmax" }
      ]
    },
    training: {
      epochs: 100,
      batch_size: 32,
      learning_rate: 0.001,
      optimizer: "adam"
    },
    divergent: {
      enabled: true,
      pattern: "lateral", // quantum, chaotic, associative, evolutionary
      factor: 0.5
    }
  },
  tier: "small",
  user_id: "your_user_id"
})
示例:用于时间序列的 LSTM
mcp__flow-nexus__neural_train({
  config: {
    architecture: {
      type: "lstm",
      layers: [
        { type: "lstm", units: 128, return_sequences: true },
        { type: "dropout", rate: 0.2 },
        { type: "lstm", units: 64 },
        { type: "dense", units: 1, activation: "linear" }
      ]
    },
    training: {
      epochs: 150,
      batch_size: 64,
      learning_rate: 0.01,
      optimizer: "adam"
    }
  },
  tier: "medium"
})
示例:Transformer 架构
mcp__flow-nexus__neural_train({
  config: {
    architecture: {
      type: "transformer",
      layers: [
        { type: "embedding", vocab_size: 10000, embedding_dim: 512 },
        { type: "transformer_encoder", num_heads: 8, ff_dim: 2048 },
        { type: "global_average_pooling" },
        { type: "dense", units: 128, activation: "relu" },
        { type: "dense", units: 2, activation: "softmax" }
      ]
    },
    training: {
      epochs: 50,
      batch_size: 16,
      learning_rate: 0.0001,
      optimizer: "adam"
    }
  },
  tier: "large"
})
2. 模型推理

使用训练好的模型进行预测。

mcp__flow-nexus__neural_predict({
  model_id: "model_abc123",
  input: [
    [0.5, 0.3, 0.2, 0.1],
    [0.8, 0.1, 0.05, 0.05],
    [0.2, 0.6, 0.15, 0.05]
  ],
  user_id: "your_user_id"
})

响应:

{
  "predictions": [
    [0.12, 0.85, 0.03],
    [0.89, 0.08, 0.03],
    [0.05, 0.92, 0.03]
  ],
  "inference_time_ms": 45,
  "model_version": "1.0.0"
}
3. 模板市场

浏览并部署市场中的预训练模型。

列出可用模板
mcp__flow-nexus__neural_list_templates({
  category: "classification", // timeseries, regression, nlp, vision, anomaly, generative
  tier: "free", // or "paid"
  search: "sentiment",
  limit: 20
})

响应:

{
  "templates": [
    {
      "id": "sentiment-analysis-v2",
      "name": "Sentiment Analysis Classifier",
      "description": "Pre-trained BERT model for sentiment analysis",
      "category": "nlp",
      "accuracy": 0.94,
      "downloads": 1523,
      "tier": "free"
    },
    {
      "id": "image-classifier-resnet",
      "name": "ResNet Image Classifier",
      "description": "ResNet-50 for image classification",
      "category": "vision",
      "accuracy": 0.96,
      "downloads": 2341,
      "tier": "paid"
    }
  ]
}
部署模板
mcp__flow-nexus__neural_deploy_template({
  template_id: "sentiment-analysis-v2",
  custom_config: {
    training: {
      epochs: 50,
      learning_rate: 0.0001
    }
  },
  user_id: "your_user_id"
})
4. 分布式训练集群

通过分布式计算,在多个 E2B 沙盒中训练大型模型。

初始化集群
mcp__flow-nexus__neural_cluster_init({
  name: "large-model-cluster",
  architecture: "transformer", // transformer, cnn, rnn, gnn, hybrid
  topology: "mesh", // mesh, ring, star, hierarchical
  consensus: "proof-of-learning", // byzantine, raft, gossip
  daaEnabled: true, // Decentralized Autonomous Agents
  wasmOptimization: true
})

响应:

{
  "cluster_id": "cluster_xyz789",
  "name": "large-model-cluster",
  "status": "initializing",
  "topology": "mesh",
  "max_nodes": 100,
  "created_at": "2025-10-19T10:30:00Z"
}
部署工作节点
// Deploy parameter server
mcp__flow-nexus__neural_node_deploy({
  cluster_id: "cluster_xyz789",
  node_type: "parameter_server",
  model: "large",
  template: "nodejs",
  capabilities: ["parameter_management", "gradient_aggregation"],
  autonomy: 0.8
})

// Deploy worker nodes
mcp__flow-nexus__neural_node_deploy({
  cluster_id: "cluster_xyz789",
  node_type: "worker",
  model: "xl",
  role: "worker",
  capabilities: ["training", "inference"],
  layers: [
    { type: "transformer_encoder", num_heads: 16 },
    { type: "feed_forward", units: 4096 }
  ],
  autonomy: 0.9
})

// Deploy aggregator
mcp__flow-nexus__neural_node_deploy({
  cluster_id: "cluster_xyz789",
  node_type: "aggregator",
  model: "large",
  capabilities: ["gradient_aggregation", "model_synchronization"]
})
连接集群拓扑
mcp__flow-nexus__neural_cluster_connect({
  cluster_id: "cluster_xyz789",
  topology: "mesh" // Override default if needed
})
开始分布式训练
mcp__flow-nexus__neural_train_distributed({
  cluster_id: "cluster_xyz789",
  dataset: "imagenet", // or custom dataset identifier
  epochs: 100,
  batch_size: 128,
  learning_rate: 0.001,
  optimizer: "adam", // sgd, rmsprop, adagrad
  federated: true // Enable federated learning
})

联邦学习示例:

mcp__flow-nexus__neural_train_distributed({
  cluster_id: "cluster_xyz789",
  dataset: "medical_images_distributed",
  epochs: 200,
  batch_size: 64,
  learning_rate: 0.0001,
  optimizer: "adam",
  federated: true, // Data stays on local nodes
  aggregation_rounds: 50,
  min_nodes_per_round: 5
})
监控集群状态
mcp__flow-nexus__neural_cluster_status({
  cluster_id: "cluster_xyz789"
})

响应:

{
  "cluster_id": "cluster_xyz789",
  "status": "training",
  "nodes": [
    {
      "node_id": "node_001",
      "type": "parameter_server",
      "status": "active",
      "cpu_usage": 0.75,
      "memory_usage": 0.82
    },
    {
      "node_id": "node_002",
      "type": "worker",
      "status": "active",
      "training_progress": 0.45
    }
  ],
  "training_metrics": {
    "current_epoch": 45,
    "total_epochs": 100,
    "loss": 0.234,
    "accuracy": 0.891
  }
}
运行分布式推理
mcp__flow-nexus__neural_predict_distributed({
  cluster_id: "cluster_xyz789",
  input_data: JSON.stringify([
    [0.1, 0.2, 0.3],
    [0.4, 0.5, 0.6]
  ]),
  aggregation: "ensemble" // mean, majority, weighted, ensemble
})
终止集群
mcp__flow-nexus__neural_cluster_terminate({
  cluster_id: "cluster_xyz789"
})
5. 模型管理
列出你的模型
mcp__flow-nexus__neural_list_models({
  user_id: "your_user_id",
  include_public: true
})

响应:

{
  "models": [
    {
      "model_id": "model_abc123",
      "name": "Custom Classifier v1",
      "architecture": "feedforward",
      "accuracy": 0.92,
      "created_at": "2025-10-15T14:20:00Z",
      "status": "trained"
    },
    {
      "model_id": "model_def456",
      "name": "LSTM Forecaster",
      "architecture": "lstm",
      "mse": 0.0045,
      "created_at": "2025-10-18T09:15:00Z",
      "status": "training"
    }
  ]
}
检查训练状态
mcp__flow-nexus__neural_training_status({
  job_id: "job_training_xyz"
})

响应:

{
  "job_id": "job_training_xyz",
  "status": "training",
  "progress": 0.67,
  "current_epoch": 67,
  "total_epochs": 100,
  "current_loss": 0.234,
  "estimated_completion": "2025-10-19T12:45:00Z"
}
性能基准测试
mcp__flow-nexus__neural_performance_benchmark({
  model_id: "model_abc123",
  benchmark_type: "comprehensive" // inference, throughput, memory, comprehensive
})

响应:

{
  "model_id": "model_abc123",
  "benchmarks": {
    "inference_latency_ms": 12.5,
    "throughput_qps": 8000,
    "memory_usage_mb": 245,
    "gpu_utilization": 0.78,
    "accuracy": 0.92,
    "f1_score": 0.89
  },
  "timestamp": "2025-10-19T11:00:00Z"
}
创建验证工作流
mcp__flow-nexus__neural_validation_workflow({
  model_id: "model_abc123",
  user_id: "your_user_id",
  validation_type: "comprehensive" // performance, accuracy, robustness, comprehensive
})
6. 发布和市场
将模型发布为模板
mcp__flow-nexus__neural_publish_template({
  model_id: "model_abc123",
  name: "High-Accuracy Sentiment Classifier",
  description: "Fine-tuned BERT model for sentiment analysis with 94% accuracy",
  category: "nlp",
  price: 0, // 0 for free, or credits amount
  user_id: "your_user_id"
})
为模板评分
mcp__flow-nexus__neural_rate_template({
  template_id: "sentiment-analysis-v2",
  rating: 5,
  review: "Excellent model! Achieved 95% accuracy on my dataset.",
  user_id: "your_user_id"
})

常见用例

使用 CNN 进行图像分类
// Initialize cluster for large-scale image training
const cluster = await mcp__flow-nexus__neural_cluster_init({
  name: "image-classification-cluster",
  architecture: "cnn",
  topology: "hierarchical",
  wasmOptimization: true
})

// Deploy worker nodes
await mcp__flow-nexus__neural_node_deploy({
  cluster_id: cluster.cluster_id,
  node_type: "worker",
  model: "large",
  capabilities: ["training", "data_augmentation"]
})

// Start training
await mcp__flow-nexus__neural_train_distributed({
  cluster_id: cluster.cluster_id,
  dataset: "custom_images",
  epochs: 100,
  batch_size: 64,
  learning_rate: 0.001,
  optimizer: "adam"
})
NLP 情感分析
// Use pre-built template
const deployment = await mcp__flow-nexus__neural_deploy_template({
  template_id: "sentiment-analysis-v2",
  custom_config: {
    training: {
      epochs: 30,
      batch_size: 16
    }
  }
})

// Run inference
const result = await mcp__flow-nexus__neural_predict({
  model_id: deployment.model_id,
  input: ["This product is amazing!", "Terrible experience."]
})
时间序列预测
// Train LSTM model
const training = await mcp__flow-nexus__neural_train({
  config: {
    architecture: {
      type: "lstm",
      layers: [
        { type: "lstm", units: 128, return_sequences: true },
        { type: "dropout", rate: 0.2 },
        { type: "lstm", units: 64 },
        { type: "dense", units: 1 }
      ]
    },
    training: {
      epochs: 150,
      batch_size: 64,
      learning_rate: 0.01,
      optimizer: "adam"
    }
  },
  tier: "medium"
})

// Monitor progress
const status = await mcp__flow-nexus__neural_training_status({
  job_id: training.job_id
})
用于隐私保护的联邦学习
// Initialize federated cluster
const cluster = await mcp__flow-nexus__neural_cluster_init({
  name: "federated-medical-cluster",
  architecture: "transformer",
  topology: "mesh",
  consensus: "proof-of-learning",
  daaEnabled: true
})

// Deploy nodes across different locations
for (let i = 0; i < 5; i++) {
  await mcp__flow-nexus__neural_node_deploy({
    cluster_id: cluster.cluster_id,
    node_type: "worker",
    model: "large",
    autonomy: 0.9
  })
}

// Train with federated learning (data never leaves nodes)
await mcp__flow-nexus__neural_train_distributed({
  cluster_id: cluster.cluster_id,
  dataset: "medical_records_distributed",
  epochs: 200,
  federated: true,
  aggregation_rounds: 100
})

架构模式

前馈网络

适用于:分类、回归、简单的模式识别

{
  type: "feedforward",
  layers: [
    { type: "dense", units: 256, activation: "relu" },
    { type: "dropout", rate: 0.3 },
    { type: "dense", units: 128, activation: "relu" },
    { type: "dense", units: 10, activation: "softmax" }
  ]
}
LSTM 网络

适用于:时间序列、序列、预测

{
  type: "lstm",
  layers: [
    { type: "lstm", units: 128, return_sequences: true },
    { type: "lstm", units: 64 },
    { type: "dense", units: 1 }
  ]
}
Transformers

适用于:NLP、注意力机制、大规模文本

{
  type: "transformer",
  layers: [
    { type: "embedding", vocab_size: 10000, embedding_dim: 512 },
    { type: "transformer_encoder", num_heads: 8, ff_dim: 2048 },
    { type: "global_average_pooling" },
    { type: "dense", units: 2, activation: "softmax" }
  ]
}
GAN

适用于:生成任务、图像合成

{
  type: "gan",
  generator_layers: [...],
  discriminator_layers: [...]
}
自编码器

适用于:降维、异常检测

{
  type: "autoencoder",
  encoder_layers: [
    { type: "dense", units: 128, activation: "relu" },
    { type: "dense", units: 64, activation: "relu" }
  ],
  decoder_layers: [
    { type: "dense", units: 128, activation: "relu" },
    { type: "dense", units: input_dim, activation: "sigmoid" }
  ]
}

最佳实践

  1. 从小规模开始:从 nano 或 mini 级别入手进行实验
  2. 使用模板:利用市场模板处理常见任务
  3. 监控训练:定期检查状态,以便及早发现问题
  4. 对模型进行基准测试:在生产部署前务必进行基准测试
  5. 分布式训练:大型模型(>1B 参数)请使用集群
  6. 联邦学习:用于对隐私敏感的数据
  7. 对模型进行版本管理:将成功的模型发布为模板,以便重复使用
  8. 全面验证:部署前使用验证工作流

故障排除

训练停滞
// Check cluster status
const status = await mcp__flow-nexus__neural_cluster_status({
  cluster_id: "cluster_id"
})

// Terminate and restart if needed
await mcp__flow-nexus__neural_cluster_terminate({
  cluster_id: "cluster_id"
})
准确率低
  • 增加训练轮数
  • 调整学习率
  • 添加正则化(dropout)
  • 尝试不同的优化器
  • 使用数据增强
内存不足
  • 减小批次大小
  • 使用更小的模型级别
  • 启用梯度累积
  • 使用分布式训练

相关技能

  • flow-nexus-sandbox - E2B 沙盒管理
  • flow-nexus-swarm - AI 蜂群编排
  • flow-nexus-workflow - 工作流自动化

资源

  • Flow Nexus 文档: https:/$flow-nexus.ruv.io$docs
  • 神经网络指南: https:/$flow-nexus.ruv.io$docs$neural
  • 模板市场: https:/$flow-nexus.ruv.io$templates
  • API 参考: https:/$flow-nexus.ruv.io$api

注意:分布式训练需要身份验证。请在 https:/$flow-nexus.ruv.io 注册,或使用 npx flow-nexus@latest register。

评论

支持 Markdown