AI Intelligence Features
r3 is an open-source local Redis memory MCP server that includes powerful AI intelligence features. These capabilities automatically enhance your memory storage with semantic understanding, entity extraction, and knowledge graph construction.
Install with npx @n3wth/r3 to get started immediately.
Overview
r3's AI intelligence features are enabled by default and provide:
- Real vector embeddings for semantic search (384 dimensions)
- Automatic entity extraction from text
- Relationship mapping between entities
- Knowledge graph construction
- Multi-factor relevance scoring
All processing happens 100% locally with no external API calls, keeping your data private and responses fast.
Entity Extraction
Every memory is automatically analyzed to extract meaningful entities:
Extracted Entity Types
- People - Names and references to individuals
- Organizations - Companies, teams, groups
- Technologies - Programming languages, frameworks, tools
- Projects - Project names and initiatives
- Dates - Temporal references and timelines
- Places - Locations and geographical references
Example
typescriptconst memory ="Sarah from Marketing works on the Dashboard project with React and TypeScript";// Automatically extracts:// - People: ["Sarah"]// - Organizations: ["Marketing"]// - Projects: ["Dashboard"]// - Technologies: ["React", "TypeScript"]// - Relationships: [// { from: "Sarah", to: "Marketing", type: "WORKS_FOR" },// { from: "Dashboard", to: "React", type: "USES" }// ]
Semantic Search
Search memories by meaning, not just keywords:
How It Works
- Vector Embeddings - Each memory is converted to a 384-dimensional vector
- Semantic Similarity - Find memories with similar meaning
- Multi-factor Scoring - Combines multiple relevance signals
Relevance Scoring Algorithm
typescript// Final score calculationconst relevanceScore =semanticSimilarity * 0.5 + // Meaning-based matchingkeywordOverlap * 0.2 + // Traditional text matchingentityOverlap * 0.15 + // Shared entitiesrecencyBonus * 0.1 + // Prefer recent memoriesaccessFrequency * 0.05; // Popular memories rank higher
Example Usage
typescript// Semantic search finds related conceptsconst results = await recall.search({query: "machine learning and AI",limit: 5,});// Will find memories about:// - "neural networks and deep learning"// - "artificial intelligence applications"// - "ML models and training data"// Even without exact keyword matches!
Knowledge Graph
Build a connected graph of your knowledge:
Graph Structure
typescriptinterface KnowledgeGraph {nodes: Array<{id: string;type: "person" | "organization" | "technology" | "project";name: string;mentions: number;}>;edges: Array<{from: string;to: string;type: RelationshipType;confidence: number;}>;}
Relationship Types
WORKS_FOR- Person works at organizationMANAGES- Person manages person/projectUSES- Project uses technologyBUILT_WITH- Created using technologyDEPENDS_ON- Technical dependencyINTEGRATES_WITH- System integrationLOCATED_IN- Geographical relationshipPART_OF- Hierarchical relationship
MCP Tools
When using r3 as an MCP server with Antigravity CLI:
bash# Extract entities from textextract_entities(text: string)# Query knowledge graphget_knowledge_graph(entity_type?: string,entity_name?: string,relationship_type?: string,limit?: number)# Find connections between entitiesfind_connections(from_entity: string,to_entity?: string,max_depth?: number)
Performance
All AI features are optimized for speed:
| Operation | Latency | Notes |
|---|---|---|
| Embedding generation | <5ms | 384-dimensional vectors |
| Entity extraction | <10ms | Using wink-nlp |
| Semantic search | <10ms | For 1000+ memories |
| Graph traversal | <5ms | BFS with depth limit |
Configuration
Default Mode (AI Enabled)
typescript// AI features are enabled by defaultconst recall = new Recall();// Or explicitlyconst recall = new Recall({intelligenceMode: "enhanced",});
Basic Mode (Opt-out)
typescript// Disable AI features if neededconst recall = new Recall({intelligenceMode: 'basic'});// Or via environment variableINTELLIGENCE_MODE=basic npx r3// Or via CLI flagnpx r3 --basic
Technical Details
Embedding Model
- Model: all-MiniLM-L6-v2
- Dimensions: 384
- Library: transformers.js
- Processing: CPU-optimized
- Cache: Embeddings are cached for reuse
NLP Engine
- Library: wink-nlp
- Model: wink-eng-lite-web-model
- Features: Tokenization, POS tagging, NER
- Language: English
Vector Storage
- Library: Vectra
- Index: Local file-based
- Search: Cosine similarity
- Updates: Incremental indexing
Privacy & Security
- 100% Local Processing - No data leaves your machine
- No External APIs - All models run locally
- Cached Models - Downloaded once, used offline
- Encrypted Storage - Optional encryption for vectors
Examples
Building a Personal Knowledge Base
typescript// Store memories with automatic intelligenceawait recall.add({content:"Met with Dr. Chen about the AI research project. She suggested using transformer models for better accuracy.",userId: "researcher",});// Later, find connectionsconst connections = await recall.findConnections({from: "Dr. Chen",to: "transformer models",});// Returns: Dr. Chen -> AI research project -> transformer models
Project Context Management
typescript// Store project contextawait recall.add({content:"Dashboard project uses React v18, TypeScript v5, and connects to PostgreSQL database on AWS RDS.",userId: "project-dashboard",});// Query technology stackconst techStack = await recall.getKnowledgeGraph({entityType: "technology",userId: "project-dashboard",});
Team Knowledge Sharing
typescript// Store team informationawait recall.add({content:"Sarah leads the frontend team and reports to Mike. She specializes in React and accessibility.",userId: "team",});// Find team relationshipsconst teamGraph = await recall.getKnowledgeGraph({relationshipType: "REPORTS_TO",userId: "team",});
Troubleshooting
High Memory Usage
The embedding model uses ~100MB RAM. To reduce memory:
typescript// Use basic mode for low-memory environmentsconst recall = new Recall({intelligenceMode: "basic",});
Slow First Load
Models are downloaded on first use (~50MB). This is one-time only.
Entity Extraction Accuracy
For better extraction:
- Use proper capitalization for names
- Include context around entities
- Use full sentences when possible
What's Next
Future enhancements planned:
- Multi-language support
- Custom entity types
- Graph visualization API
- Clustering and topic modeling
- Incremental learning from feedback