AgentDB Learning Plugins について
自律エージェント向けに、AgentDBの強化学習プラグインを作成、学習、管理するスキルです。9種類のアルゴリズムを扱い、CLIとAPIで経験データに基づく学習を行います。
主な機能
- 019種類の強化学習アルゴリズム
- 02CLIによるプラグインの作成と管理
- 03AgentDBアダプターによる学習
- 04経験データの保存とリプレイ
- 05推論検索による評価
- 06WASMによるニューラル推論の高速化
活用シーン
- 01記録済みのエージェント経験からの学習
- 02離散または連続的な判断を行うエージェントの学習
- 03人間のフィードバックを学習に反映
- 04複数エージェントを使った学習
MCP 対応
READMEは `npx agentdb@latest mcp` によるMCP連携に言及していますが、具体的な機能は説明していません。
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ ruvnet/ ruflo --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. アクティブラーニング
種類:クエリベース学習 最適な用途:ラベル効率の高い学習、ヒューマン・イン・ザ・ループ 強み:ラベル付けのコストを最小限に抑え、不確実性の高いサンプルに重点を置きます
ユースケース:
- 人間からのフィードバックの取り込み
- ラベル効率の高いトレーニング
- 不確実性サンプリング
- アノテーションコストの削減
6. 敵対的トレーニング
種類:ロバスト性の強化 最適な用途:安全性、摂動に対するロバスト性 強み:モデルのロバスト性を高め、敵対的攻撃を防御します
ユースケース:
- セキュリティアプリケーション
- ロバストな意思決定
- 敵対的攻撃への防御
- 安全性テスト
7. カリキュラム学習
種類:難易度を段階的に上げるトレーニング 最適な用途:複雑なタスク、収束の高速化 強み:安定した学習を実現し、難しいタスクでも収束を高速化します
ユースケース:
- 複雑な複数段階のタスク
- 探索が難しい問題
- スキルの組み合わせ
- 転移学習
8. フェデレーテッドラーニング
種類:分散学習 最適な用途:プライバシー、分散データ 強み:プライバシーを保護し、拡張性に優れています
ユースケース:
- マルチエージェントシステム
- プライバシーに配慮が必要なデータ
- 分散トレーニング
- 協調学習
9. マルチタスク学習
種類:転移学習 最適な用途:関連するタスク、知識の共有 強み:新しいタスクの学習を高速化し、汎化性能を高めます
ユースケース:
- タスクファミリー
- 転移学習
- ドメイン適応
- メタ学習
トレーニングのワークフロー
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)
詳細はこちら
- アルゴリズムの論文:詳細な論文については docs$algorithms/ をご覧ください
- GitHub:https:/$github.com$ruvnet$agentic-flow$tree$main$packages$agentdb
- MCP 統合:
npx agentdb@latest mcp - ウェブサイト:https:/$agentdb.ruv.io
カテゴリー:機械学習/強化学習 難易度:中級〜上級 推定所要時間:30〜60 分