@claude-flow/neural

中文文档
3.0.3发布于 2026/11/06MITTypeScriptES Module近 30 天下载 27.1万

Claude Flow的自适应性神经结构(SONA)——适应性学习、轨迹跟踪、模式再利用、7个RL算法(PPO/A2C/DQN/Q-Llearning/SARSA/决定变换器/Curiosity),闪光注意、MOE路由、LORA、EWC++用于持续脱落

中文使用文档
文档目录17 节
  1. 这是什么
  2. 安装
  3. 独立使用(没有 Ruflo CLI)
  4. 快速启动( 建议)
  5. 下层 API: SONA 管理器
  6. 学习模式
  7. 理性银行+模式Learner(可单独访问)
  8. RL算法(包括7个)
  9. LoRA 配置
  10. EWC++ (弹性重量合并)
  11. 事件系统
  12. 业绩指标
  13. 类型脚本
  14. 与 @claude-flow/cli
  15. 依赖关系
  16. 相关软件包
  17. 许可证

@ claude- flow/ 神经

npm version npm downloads License: MIT TypeScript

Claude Flow V3——适应性学习,轨迹跟踪,图案再用,以及7个RL算法的自优化神经架构(SONA)在一个单包中.

这是什么

一个自成一体的学习模块,记录了代理执行轨迹,将其分馏为可再用模式,为新任务取回匹配,并通过SONA + LORA + EWC++来适应. 被设计为克洛德·福林克(Claude Flow CLI)的智能层所构成的底物——包拥有算法,CLI拥有管弦乐.

安装

npm install @claude-flow/neural

注释(2026-05-16): @claude-flow/[email protected]+ 针头 @ruvector/sona 到确切的已知善 0.1.5 因为 @ruvector/[email protected] 作为空出版物(README +)发售 package.json 仅 -- -- 没有 index.js没有原生的垃圾桶). 先前的α.8 使用过的 "latest" 并打破了每一个新安装。 针会 一直停留到 @ruvector/[email protected]+ 有内容的船只.

独立使用(没有 Ruflo CLI)

// route a task across 8 specialized experts (MoE) — no other deps
import { getMoERouter } from '@claude-flow/neural';

const router = getMoERouter();
await router.initialize();

const decision = await router.route(
  new Float32Array(384).fill(0.1),   // task embedding
  { task: 'optimize-query', complexity: 0.7 },
);
console.log(decision.expert, decision.confidence);
// → 'performance', 0.83  (or whichever expert wins)

NeuralLearningSystem 是高级的切入点——它连接 SONAManager, (中文(简体) ), ReasoningBank,以及 PatternLearner 所以来电者不必:

import { createNeuralLearningSystem } from '@claude-flow/neural';

const sys = createNeuralLearningSystem('balanced');
await sys.initialize();

// Track a task
const id = sys.beginTask('Refactor auth middleware', 'code');

// Record steps as the agent works (Float32Array embeddings)
sys.recordStep(id, 'analyzed-imports', 0.8, embedding1);
sys.recordStep(id, 'extracted-helpers',  0.9, embedding2);

// Complete — fires distillation + pattern extraction automatically
await sys.completeTask(id, /* qualityScore */ 0.85);

// Retrieve relevant memories for the next similar task
const memories = await sys.retrieveMemories(queryEmbedding, /* k */ 3);
const patterns = await sys.findPatterns(queryEmbedding, 3);

// Periodic learning sweep (consolidation + EWC)
await sys.triggerLearning();

console.log(sys.getStats());
// → { sona: NeuralStats, reasoningBank: { ... }, patternLearner: { ... } }

下层 API: SONA 管理器

对于想要直接管理轨迹和模式的呼叫者:

import { createSONAManager, type Trajectory } from '@claude-flow/neural';

const sona = createSONAManager('balanced');
await sona.initialize();

// domain ∈ 'code' | 'creative' | 'reasoning' | 'chat' | 'math' | 'general'
const trajectoryId = sona.beginTrajectory('code-review-task', 'code');

sona.recordStep(trajectoryId, 'analyze-code',     0.8, stateEmbedding);
sona.recordStep(trajectoryId, 'generate-feedback', 0.9, nextStateEmbedding);

const trajectory: Trajectory = sona.completeTrajectory(trajectoryId, 0.85);

// Query patterns
const matches = await sona.findSimilarPatterns(contextEmbedding, /* k */ 3);

// Trigger consolidation manually
await sona.triggerLearning('manual');
sona.consolidateEWC();

学习模式

模式适应质量内存使用大小写
实时< 0. 5ms (单位:千美元)70%+25 个 MB低纬度生产
平衡 (默认)< 18ms [1] 时第75条50 MB (英语)一般用途
研究< 100 分钟95%+100 MB (百兆瓦)深入探索
边缘< 1 分钟80%+5 个 MB资源受限
批次< 50 分钟第八十五条75 MB (英语)高通量
await sys.setMode('research'); // or directly: await sona.setMode('research')

理性银行+模式Learner(可单独访问)

NeuralLearningSystem 作曲;也可以单独使用:

import {
  createReasoningBank,
  createPatternLearner,
  createSONALearningEngine,
} from '@claude-flow/neural';

const bank = createReasoningBank();
await bank.storeTrajectory(trajectory);
await bank.judge(trajectory);
const distilled = await bank.distill(trajectory);

const learner = createPatternLearner();
learner.extractPattern(trajectory, distilled);
const matches = await learner.findMatches(queryEmbedding, 5);

const engine = createSONALearningEngine();
const adapted = await engine.adapt(input, /* domain */ 'code');

RL算法(包括7个)

导入使用 Algorithm 在适用的情况下,后缀:

import {
  PPOAlgorithm,         createPPO,         DEFAULT_PPO_CONFIG,
  A2CAlgorithm,         createA2C,         DEFAULT_A2C_CONFIG,
  DQNAlgorithm,         createDQN,         DEFAULT_DQN_CONFIG,
  QLearning,            createQLearning,   DEFAULT_QLEARNING_CONFIG,
  SARSAAlgorithm,       createSARSA,       DEFAULT_SARSA_CONFIG,
  DecisionTransformer,  createDecisionTransformer, DEFAULT_DT_CONFIG,
  CuriosityModule,      createCuriosity,   DEFAULT_CURIOSITY_CONFIG,
} from '@claude-flow/neural';

const ppo = createPPO({ learningRate: 0.0003, epsilon: 0.2, valueCoef: 0.5 });
const dqn = createDQN({ learningRate: 0.001, gamma: 0.99, epsilon: 0.1, targetUpdateFreq: 100 });

// Generic factory — pick algorithm by name
import { createAlgorithm, getDefaultConfig } from '@claude-flow/neural';
const algo = createAlgorithm('ppo', getDefaultConfig('ppo'));

LoRA 配置

const config = sona.getLoRAConfig();
// { rank: 4, alpha: 8, dropout: 0.05, targetModules: ['q_proj','v_proj','k_proj','o_proj'], microLoRA: false }

const weights = sona.initializeLoRAWeights('code-generation');

EWC++ (弹性重量合并)

防止在适应新领域时发生灾难性的遗忘:

const config = sona.getEWCConfig();
// { lambda: 2000, decay: 0.9, fisherSamples: 100, minFisher: 1e-8, online: true }

// After learning a new task, consolidate before moving on
sona.consolidateEWC();

事件系统

sys.addEventListener((event) => {
  switch (event.type) {
    case 'trajectory_started':  console.log(`Started: ${event.trajectoryId}`); break;
    case 'trajectory_completed': console.log(`Quality: ${event.qualityScore}`); break;
    case 'pattern_matched':     console.log(`Pattern ${event.patternId} matched`); break;
    case 'learning_triggered':  console.log(`Learning: ${event.reason}`); break;
    case 'mode_changed':        console.log(`${event.fromMode} → ${event.toMode}`); break;
  }
});

业绩指标

度量衡目标典型
适应延迟< 0.05 毫秒(秒)0.02毫秒(分钟)
模式检索< 1 分钟0.5 毫秒( 分钟)
学习步骤< 10 分钟5分钟
质量改进+55% (单位:千美元)+40 - 60%
内存间接费用< 50 MB 设备25-75甲基溴

类型脚本

import type {
  // Core
  SONAMode, SONAModeConfig, ModeOptimizations,
  Trajectory, TrajectoryStep, TrajectoryVerdict, DistilledMemory,
  Pattern, PatternMatch, PatternEvolution,

  // RL
  RLAlgorithm, RLConfig,
  PPOConfig, DQNConfig, A2CConfig, QLearningConfig, SARSAConfig,
  DecisionTransformerConfig, CuriosityConfig,

  // Neural
  LoRAConfig, LoRAWeights, EWCConfig, EWCState,
  NeuralStats, NeuralEvent, NeuralEventListener,
} from '@claude-flow/neural';

与 @claude-flow/cli

CLI的情报层(hooks_intelligence_*, (中文(简体) ), neural_* MCP工具, /intelligence 仪表板)是主要的消费者. 汇合的第一阶段(# 1773) 在 cli/src/memory/neural-package-bridge.ts 那些懒惰的货 NeuralLearningSystem 所以Cli的智能处理器 可以调用到包表面 与现有的本地执行。 未来阶段迁移cli's LocalSonaCoordinator 财务报告和审定财务报表 LocalReasoningBank 来包装此软件包 SONALearningEngine 财务报告和审定财务报表 ReasoningBankAdapter。 。 。 .

如果你正在建造一个需要神经学习的Ruflo插件,取决于 @claude-flow/neural 而不是直接进入cli内部.

依赖关系

许可证

麻省理工学院

版本与发布记录

@claude-flow/neural 共发布 10 个版本,首次发布于 2026/01/07;过去 12 个月发布了 10 个版本。

版本发布日期距今
3.0.3latest2026/11/063 天前
3.0.22026/11/028 天前
3.0.1alphav3alpha2026/10/2813 天前
3.0.02026/09/291 个月前
3.0.0-alpha.102026/09/261 个月前
3.0.0-alpha.92026/05/175 个月前

关于 @claude-flow/neural 的常见问题

@claude-flow/neural 是什么?

Claude Flow的自适应性神经结构(SONA)——适应性学习、轨迹跟踪、模式再利用、7个RL算法(PPO/A2C/DQN/Q-Llearning/SARSA/决定变换器/Curiosity),闪光注意、MOE路由、LORA、EWC++用于持续脱落

如何安装 @claude-flow/neural?

在项目目录运行 npm install @claude-flow/neural,或使用 pnpm add / yarn add / bun add。

@claude-flow/neural 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@claude-flow/neural 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@claude-flow/neural 可以商用吗?

@claude-flow/neural 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@claude-flow/neural 的下载量有多少?

根据 npm 官方下载统计,@claude-flow/neural 在 2026/10/10 – 2026/11/08 这 30 天内被下载 270,684 次,日均约 9,023 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@claude-flow/neural 还在维护吗?

最新版本 3.0.3 发布于 2026/11/06(3 天前);至今共发布 10 个版本,其中过去 12 个月发布了 10 个;首次发布于 2026/01/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。