mcpField
A
AgentDB Learning Plugins

AgentDB Learning Plugins

github.com/ruvnetエージェントワークフロー101.0k39 回インストール3 日前に更新
リポジトリ

AgentDB Learning Plugins について

AgentDB Learning Pluginsは、自律型エージェント向けの学習プラグインを作成・訓練するスキルです。9種類の強化学習アルゴリズムを備え、経験から学ぶエージェントを開発する人向けに、CLIとAPIでの管理・訓練手順を示します。

主な機能

  1. 019種類の強化学習アルゴリズム
  2. 02CLIでのプラグイン作成と管理
  3. 03経験の収集とモデル訓練
  4. 04推論を用いた経験検索
  5. 05WASMによるニューラル推論の高速化

活用シーン

  1. 01記録済みの経験から学習
  2. 02離散的な意思決定を行うエージェントの訓練
  3. 03連続制御タスクへの対応
  4. 04複数エージェントでの訓練

MCP 対応

`npx agentdb@latest mcp`によるMCP連携が記載されていますが、MCPクライアントに提供するツールやリソースの説明はありません。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/ruvnet/ruview --skill agentdb-learning-plugins

インストール後、Claude Code で/agentdb-learning-pluginsを入力して読み込まれたか確認します。

詳細

AgentDB 学習プラグイン

このスキルでできること

AgentDB のプラグインシステムを介して、9 種類の強化学習アルゴリズムを利用できます。経験を通じて改善する自律エージェント向けに、学習プラグインを作成、トレーニング、デプロイします。オフライン RL(Decision Transformer)、価値ベース学習(Q-Learning)、方策勾配(Actor-Critic)、高度な手法を含みます。

パフォーマンス:WASM による高速化を活用したニューラル推論により、モデルを 10~100 倍速くトレーニングできます。

前提条件

  • Node.js 18+
  • AgentDB v1.0.7+(agentic-flow 経由)
  • 強化学習の基本的な理解(推奨)

CLI ですぐに使う

学習プラグインを作成する
# Interactive wizard
npx agentdb@latest create-plugin

# Use specific template
npx agentdb@latest create-plugin -t decision-transformer -n my-agent

# Preview without creating
npx agentdb@latest create-plugin -t q-learning --dry-run

# Custom output directory
npx agentdb@latest create-plugin -t actor-critic -o ./plugins
利用可能なテンプレートを一覧表示する
# Show all plugin templates
npx agentdb@latest list-templates

# Available templates:
# - decision-transformer (sequence modeling RL - recommended)
# - q-learning (value-based learning)
# - sarsa (on-policy TD learning)
# - actor-critic (policy gradient with baseline)
# - curiosity-driven (exploration-based)
プラグインを管理する
# List installed plugins
npx agentdb@latest list-plugins

# Get plugin information
npx agentdb@latest plugin-info my-agent

# Shows: algorithm, configuration, training status

API ですぐに使う

import { createAgentDBAdapter } from 'agentic-flow/reasoningbank';

// Initialize with learning enabled
const adapter = await createAgentDBAdapter({
  dbPath: '.agentdb/learning.db',
  enableLearning: true,       // Enable learning plugins
  enableReasoning: true,
  cacheSize: 1000,
});

// Store training experience
await adapter.insertPattern({
  id: '',
  type: 'experience',
  domain: 'game-playing',
  pattern_data: JSON.stringify({
    embedding: await computeEmbedding('state-action-reward'),
    pattern: {
      state: [0.1, 0.2, 0.3],
      action: 2,
      reward: 1.0,
      next_state: [0.15, 0.25, 0.35],
      done: false
    }
  }),
  confidence: 0.9,
  usage_count: 1,
  success_count: 1,
  created_at: Date.now(),
  last_used: Date.now(),
});

// Train learning model
const metrics = await adapter.train({
  epochs: 50,
  batchSize: 32,
});

console.log('Training Loss:', metrics.loss);
console.log('Duration:', metrics.duration, 'ms');

利用可能な学習アルゴリズム(全 9 種類)

1. Decision Transformer(推奨)

種類:オフライン強化学習 最適な用途:記録された経験からの学習、模倣学習 強み:オンラインでのインタラクションが不要、安定したトレーニング

npx agentdb@latest create-plugin -t decision-transformer -n dt-agent

ユースケース:

  • 履歴データから学習する
  • 専門家の実演から模倣学習する
  • 環境とのインタラクションなしで安全に学習する
  • シーケンスモデリングのタスク

設定:

{
  "algorithm": "decision-transformer",
  "model_size": "base",
  "context_length": 20,
  "embed_dim": 128,
  "n_heads": 8,
  "n_layers": 6
}
2. Q-Learning

種類:価値ベースの RL(オフポリシー) 最適な用途:離散行動空間、サンプル効率 強み:実績があり、シンプルで、小規模から中規模の問題に適しています

npx agentdb@latest create-plugin -t q-learning -n q-agent

ユースケース:

  • グリッドワールド、ボードゲーム
  • ナビゲーションタスク
  • リソース配分
  • 離散的な意思決定

設定:

{
  "algorithm": "q-learning",
  "learning_rate": 0.001,
  "gamma": 0.99,
  "epsilon": 0.1,
  "epsilon_decay": 0.995
}
3. SARSA

種類:価値ベースの RL(オンポリシー) 最適な用途:安全な探索、リスク重視のタスク 強み:Q-Learning より慎重で、安全性が重要な用途に適しています

npx agentdb@latest create-plugin -t sarsa -n sarsa-agent

ユースケース:

  • 安全性が極めて重要なアプリケーション
  • リスク重視の意思決定
  • 探索を伴うオンライン学習

設定:

{
  "algorithm": "sarsa",
  "learning_rate": 0.001,
  "gamma": 0.99,
  "epsilon": 0.1
}
4. Actor-Critic

種類:価値ベースラインを用いた方策勾配法 最適な用途:連続行動、分散の低減 強み:安定しており、連続行動と離散行動の両方に対応します

npx agentdb@latest create-plugin -t actor-critic -n ac-agent

ユースケース:

  • 連続制御(ロボティクス、シミュレーション)
  • 複雑な行動空間
  • マルチエージェントの協調

設定:

{
  "algorithm": "actor-critic",
  "actor_lr": 0.001,
  "critic_lr": 0.002,
  "gamma": 0.99,
  "entropy_coef": 0.01
}
5. Active Learning

種類:クエリベースの学習 最適な用途:ラベル効率の高い学習、ヒューマン・イン・ザ・ループ 強み:ラベリングコストを最小限に抑え、不確実なサンプルに重点を置きます

ユースケース:

  • 人間からのフィードバックの取り込み
  • ラベル効率の高いトレーニング
  • 不確実性サンプリング
  • アノテーションコストの削減
6. Adversarial Training

種類:ロバスト性の強化 最適な用途:安全性、摂動へのロバスト性 強み:モデルのロバスト性を高め、敵対的攻撃への防御を強化します

ユースケース:

  • セキュリティアプリケーション
  • ロバストな意思決定
  • 敵対的攻撃への防御
  • 安全性テスト
7. Curriculum Learning

種類:難易度を段階的に上げるトレーニング 最適な用途:複雑なタスク、より速い収束 強み:安定した学習、難しいタスクでのより速い収束

ユースケース:

  • 複雑な多段階タスク
  • 難しい探索問題
  • スキルの組み合わせ
  • 転移学習
8. Federated Learning

種類:分散学習 最適な用途:プライバシー、分散データ 強み:プライバシーを保護し、スケーラブルです

ユースケース:

  • マルチエージェントシステム
  • プライバシーに配慮が必要なデータ
  • 分散トレーニング
  • 協調学習
9. Multi-Task Learning

種類:転移学習 最適な用途:関連タスク、知識共有 強み:新しいタスクをより速く学習し、汎化性能を高めます

ユースケース:

  • タスク群
  • 転移学習
  • ドメイン適応
  • メタ学習

トレーニングのワークフロー

1. 経験を収集する
// Store experiences during agent execution
for (let i = 0; i < numEpisodes; i++) {
  const episode = runEpisode();

  for (const step of episode.steps) {
    await adapter.insertPattern({
      id: '',
      type: 'experience',
      domain: 'task-domain',
      pattern_data: JSON.stringify({
        embedding: await computeEmbedding(JSON.stringify(step)),
        pattern: {
          state: step.state,
          action: step.action,
          reward: step.reward,
          next_state: step.next_state,
          done: step.done
        }
      }),
      confidence: step.reward > 0 ? 0.9 : 0.5,
      usage_count: 1,
      success_count: step.reward > 0 ? 1 : 0,
      created_at: Date.now(),
      last_used: Date.now(),
    });
  }
}
2. モデルをトレーニングする
// Train on collected experiences
const trainingMetrics = await adapter.train({
  epochs: 100,
  batchSize: 64,
  learningRate: 0.001,
  validationSplit: 0.2,
});

console.log('Training Metrics:', trainingMetrics);
// {
//   loss: 0.023,
//   valLoss: 0.028,
//   duration: 1523,
//   epochs: 100
// }
3. パフォーマンスを評価する
// Retrieve similar successful experiences
const testQuery = await computeEmbedding(JSON.stringify(testState));
const result = await adapter.retrieveWithReasoning(testQuery, {
  domain: 'task-domain',
  k: 10,
  synthesizeContext: true,
});

// Evaluate action quality
const suggestedAction = result.memories[0].pattern.action;
const confidence = result.memories[0].similarity;

console.log('Suggested Action:', suggestedAction);
console.log('Confidence:', confidence);

高度なトレーニング手法

経験再生
// Store experiences in buffer
const replayBuffer = [];

// Sample random batch for training
const batch = sampleRandomBatch(replayBuffer, batchSize: 32);

// Train on batch
await adapter.train({
  data: batch,
  epochs: 1,
  batchSize: 32,
});
優先度付き経験再生
// Store experiences with priority (TD error)
await adapter.insertPattern({
  // ... standard fields
  confidence: tdError,  // Use TD error as confidence/priority
  // ...
});

// Retrieve high-priority experiences
const highPriority = await adapter.retrieveWithReasoning(queryEmbedding, {
  domain: 'task-domain',
  k: 32,
  minConfidence: 0.7,  // Only high TD-error experiences
});
マルチエージェントトレーニング
// Collect experiences from multiple agents
for (const agent of agents) {
  const experience = await agent.step();

  await adapter.insertPattern({
    // ... store experience with agent ID
    domain: `multi-agent/${agent.id}`,
  });
}

// Train shared model
await adapter.train({
  epochs: 50,
  batchSize: 64,
});

パフォーマンスの最適化

バッチトレーニング
// Collect batch of experiences
const experiences = collectBatch(size: 1000);

// Batch insert (500x faster)
for (const exp of experiences) {
  await adapter.insertPattern({ /* ... */ });
}

// Train on batch
await adapter.train({
  epochs: 10,
  batchSize: 128,  // Larger batch for efficiency
});
増分学習
// Train incrementally as new data arrives
setInterval(async () => {
  const newExperiences = getNewExperiences();

  if (newExperiences.length > 100) {
    await adapter.train({
      epochs: 5,
      batchSize: 32,
    });
  }
}, 60000);  // Every minute

推論エージェントとの統合

学習と推論を組み合わせて、パフォーマンスを向上させます。

// Train learning model
await adapter.train({ epochs: 50, batchSize: 32 });

// Use reasoning agents for inference
const result = await adapter.retrieveWithReasoning(queryEmbedding, {
  domain: 'decision-making',
  k: 10,
  useMMR: true,              // Diverse experiences
  synthesizeContext: true,    // Rich context
  optimizeMemory: true,       // Consolidate patterns
});

// Make decision based on learned experiences + reasoning
const decision = result.context.suggestedAction;
const confidence = result.memories[0].similarity;

CLI 操作

# Create plugin
npx agentdb@latest create-plugin -t decision-transformer -n my-plugin

# List plugins
npx agentdb@latest list-plugins

# Get plugin info
npx agentdb@latest plugin-info my-plugin

# List templates
npx agentdb@latest list-templates

トラブルシューティング

問題:学習が収束しない
// Reduce learning rate
await adapter.train({
  epochs: 100,
  batchSize: 32,
  learningRate: 0.0001,  // Lower learning rate
});
問題:過学習
// Use validation split
await adapter.train({
  epochs: 50,
  batchSize: 64,
  validationSplit: 0.2,  // 20% validation
});

// Enable memory optimization
await adapter.retrieveWithReasoning(queryEmbedding, {
  optimizeMemory: true,  // Consolidate, reduce overfitting
});
問題:学習が遅い
# Enable quantization for faster inference
# Use binary quantization (32x faster)

詳細はこちら


カテゴリ:機械学習/強化学習 難易度:中級~上級 推定所要時間:30~60 分

コメント