AgentDB Performance Optimization
它能做什么
这个技能展示如何让 AgentDB 更快、更轻,使用量化和快速搜索索引等技术。适合处理大规模向量集合的开发者。
适用场景
- ✓当你的向量数据库随着增长占用过多内存的时候。
- ✓当在大量记录中搜索变得越来越慢的时候。
- ✓当你需要为超大规模的向量数量规划 AgentDB 的时候。
技能链接
https://github.com/ruvnet/RuView/blob/main/.claude/skills/agentdb-optimization/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我看看,我的 AgentDB 数据库越来越大,也越来越慢。怎样才能减少它的内存占用并加快搜索?”
每周 5 个新技能,1 分钟读完。
工作原理
该技能说明可以缩小存储数据的压缩选项、能快速找到匹配项的搜索索引,以及针对重复查询的缓存。它还包含一个基准测试命令,用来衡量效果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
AgentDB Performance Optimization
What This Skill Does
Provides comprehensive performance optimization techniques for AgentDB vector databases. Achieve 150x-12,500x performance improvements through quantization, HNSW indexing, caching strategies, and batch operations. Reduce memory usage by 4-32x while maintaining accuracy.
Performance: <100µs vector search, <1ms pattern retrieval, 2ms batch insert for 100 vectors.
Prerequisites
- Node.js 18+
- AgentDB v1.0.7+ (via agentic-flow)
- Existing AgentDB database or application
Quick Start
Run Performance Benchmarks
# Comprehensive performance benchmarking
npx agentdb@latest benchmark
# Results show:
# ✅ Pattern Search: 150x faster (100µs vs 15ms)
# ✅ Batch Insert: 500x faster (2ms vs 1s for 100 vectors)
# ✅ Large-scale Query: 12,500x faster (8ms vs 100s at 1M vectors)
# ✅ Memory Efficiency: 4-32x reduction with quantization
Enable Optimizations
import { createAgentDBAdapter } from 'agentic-flow/reasoningbank';
// Optimized configuration
const adapter = await createAgentDBAdapter({
dbPath: '.agentdb/optimized.db',
quantizationType: 'binary', // 32x memory reduction
cacheSize: 1000, // In-memory cache
enableLearning: true,
enableReasoning: true,
});
Quantization Strategies
1. Binary Quantization (32x Reduction)
Best For: Large-scale deployments (1M+ vectors), memory-constrained environments Trade-off: ~2-5% accuracy loss, 32x memory reduction, 10x faster
const adapter = await createAgentDBAdapter({
quantizationType: 'binary',
// 768-dim float32 (3072 bytes) → 96 bytes binary
// 1M vectors: 3GB → 96MB
});
Use Cases:
- Mobile/edge deployment
- Large-scale vector storage (millions of vectors)
- Real-time search with memory constraints
Performance:
- Memory: 32x smaller
- Search Speed: 10x faster (bit operations)
- Accuracy: 95-98% of original
2. Scalar Quantization (4x Reduction)
Best For: Balanced performance/accuracy, moderate datasets Trade-off: ~1-2% accuracy loss, 4x memory reduction, 3x faster
const adapter = await createAgentDBAdapter({
quantizationType: 'scalar',
// 768-dim float32 (3072 bytes) → 768 bytes (uint8)
// 1M vectors: 3GB → 768MB
});
Use Cases:
- Production applications requiring high accuracy
- Medium-scale deployments (10K-1M vectors)
- General-purpose optimization
Performance:
- Memory: 4x smaller
- Search Speed: 3x faster
- Accuracy: 98-99% of original
3. Product Quantization (8-16x Reduction)
Best For: High-dimensional vectors, balanced compression Trade-off: ~3-7% accuracy loss, 8-16x memory reduction, 5x faster
const adapter = await createAgentDBAdapter({
quantizationType: 'product',
// 768-dim float32 (3072 bytes) → 48-96 bytes
// 1M vectors: 3GB → 192MB
});
Use Cases:
- High-dimensional embeddings (>512 dims)
- Image/video embeddings
- Large-scale similarity search
Performance:
- Memory: 8-16x smaller
- Search Speed: 5x faster
- Accuracy: 93-97% of original
4. No Quantization (Full Precision)
Best For: Maximum accuracy, small datasets Trade-off: No accuracy loss, full memory usage
const adapter = await createAgentDBAdapter({
quantizationType: 'none',
// Full float32 precision
});
HNSW Indexing
Hierarchical Navigable Small World - O(log n) search complexity
Automatic HNSW
AgentDB automatically builds HNSW indices:
const adapter = await createAgentDBAdapter({
dbPath: '.agentdb/vectors.db',
// HNSW automatically enabled
});
// Search with HNSW (100µs vs 15ms linear scan)
const results = await adapter.retrieveWithReasoning(queryEmbedding, {
k: 10,
});
HNSW Parameters
// Advanced HNSW configuration
const adapter = await createAgentDBAdapter({
dbPath: '.agentdb/vectors.db',
hnswM: 16, // Connections per layer (default: 16)
hnswEfConstruction: 200, // Build quality (default: 200)
hnswEfSearch: 100, // Search quality (default: 100)
});
Parameter Tuning:
- M (connections): Higher = better recall, more memory
- Small datasets (<10K): M = 8
- Medium datasets (10K-100K): M = 16
- Large datasets (>100K): M = 32
- efConstruction: Higher = better index quality, slower build
- Fast build: 100
- Balanced: 200 (default)
- High quality: 400
- efSearch: Higher = b
常见问题
压缩会降低准确率吗?
该技能说明,目标是在减少内存占用的同时保持准确率。
我怎样衡量效果?
该技能包含一个基准测试命令,可以报告搜索和插入的速度。
我需要先安装什么?
Node.js 18 或更新版本、AgentDB 1.0.7 或更高版本,以及一个已有的数据库。
详情
作者的原始描述
Optimize AgentDB performance with quantization (4-32x memory reduction), HNSW indexing (150x faster search), caching, and batch operations. Use when optimizing memory usage, improving search speed, or scaling to millions of vectors.
repo: ruvnet/RuView
热度
- GitHub 星标
- 102k
- 排名
- #826
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
AgentDB Advanced Features
102k帮你的智能体了解 AgentDB 的高级功能,例如在多台机器之间同步数据库,以及把向量搜索与元数据过滤结合起来。
AgentDB Learning Plugins
102k让你的智能体为 AgentDB 构建并训练学习插件,使用能从过去经验中不断改进的强化学习方法。
AgentDB Memory Patterns
102k让你的智能体跨会话记住对话和上下文,并以 AgentDB 作为其持久记忆存储。
AgentDB Vector Search
102k让你的智能体按含义而不是精确词语搜索文档,适合问答和知识库。