remina-v2
v0.1.9
Published
Ultimate AI Memory System with Vector + Graph + Temporal Decay
Downloads
202
Maintainers
Readme
Remina v2 - Ultimate AI Memory System
The best-in-class AI memory system with unified Vector + Graph storage, temporal decay, and intelligent memory consolidation.
Features
- Hybrid Storage: Vector (Milvus) + Graph (FalkorDB) for both semantic and relational queries
- Temporal Decay: Memories fade over time, frequently accessed ones stay strong
- Memory Consolidation: LLM-based ADD/UPDATE/DELETE decisions prevent duplicates
- Two-Tier Caching: Redis L1 cache + PostgreSQL L2 storage
- Hybrid Search: RRF fusion of vector, fulltext, and graph results
- Intent Detection: Smart query routing based on query patterns
Stack
| Component | Technology | Purpose | |-----------|------------|---------| | L1 Cache | Redis | Hot memories, session context | | L2 Storage | PostgreSQL | Source of truth, full records | | Vector | Milvus | Semantic search, embeddings | | Graph | FalkorDB | Entity-relationship traversal | | LLM | OpenAI | Fact extraction, consolidation |
Quick Start
1. Start Infrastructure
cd remina-v2
docker-compose up -d2. Install
npm install remina3. Use
import { Memory } from 'remina';
const memory = new Memory({
postgres: { connectionString: 'postgresql://remina:remina@localhost:5432/remina' },
redis: { url: 'redis://localhost:6379' },
milvus: { address: 'localhost:19530' },
falkordb: { url: 'redis://localhost:6380' },
openaiApiKey: process.env.OPENAI_API_KEY!,
});
// Add memories from conversation
await memory.add([
{ role: 'user', content: 'My name is Bob. I run Merkle Palace hotel.' },
{ role: 'assistant', content: 'Nice to meet you Bob!' },
{ role: 'user', content: 'The hotel has three room types: Deluxe, Standard, and Heritage.' },
], 'user-123');
// Search - works for both semantic AND relational queries
const results = await memory.search('What room types does Merkle Palace have?', 'user-123');
console.log(results.memories);
// [{ content: 'Merkle Palace has three room types: Deluxe, Standard, and Heritage', ... }]
console.log(results.relations);
// [
// { source: 'Merkle Palace', relationship: 'HAS_ROOM_TYPE', target: 'Deluxe', fact: '...' },
// { source: 'Merkle Palace', relationship: 'HAS_ROOM_TYPE', target: 'Standard', fact: '...' },
// { source: 'Merkle Palace', relationship: 'HAS_ROOM_TYPE', target: 'Heritage', fact: '...' },
// ]
// Clean up
await memory.close();API
Memory
class Memory {
constructor(config: MemoryConfig)
// Core operations
add(messages: string | Message[], userId: string): Promise<AddResult>
search(query: string, userId: string, limit?: number): Promise<SearchResult>
get(memoryId: string): Promise<MemoryRecord | null>
getAll(userId: string, limit?: number): Promise<MemoryRecord[]>
update(memoryId: string, content: string): Promise<void>
delete(memoryId: string): Promise<DeleteResult>
deleteAll(userId: string): Promise<DeleteResult>
// Graph operations
getEntity(entityId: string): Promise<Entity | null>
getEntities(userId: string, limit?: number): Promise<Entity[]>
getRelationships(userId: string, limit?: number): Promise<Relationship[]>
traverse(entityId: string, hops?: number): Promise<Entity[]>
// Lifecycle
close(): Promise<void>
}Configuration
interface MemoryConfig {
// Required connections
postgres: { connectionString: string }
redis: { url: string }
milvus: { address: string; token?: string }
falkordb: { url: string }
// LLM
openaiApiKey: string
openaiModel?: string // Default: 'gpt-4o-mini'
embeddingModel?: string // Default: 'text-embedding-3-small'
// Optional tuning
decay?: {
halfLifeDays?: number // Default: 30
frequencyBoost?: number // Default: 0.1
importanceWeight?: number // Default: 0.3
}
cache?: {
memoryTtlSeconds?: number // Default: 3600
searchTtlSeconds?: number // Default: 300
enabled?: boolean // Default: true
}
}How It Works
Write Path
- Extract Facts: LLM extracts memorable facts from conversation
- Consolidate: Compare with existing memories, decide ADD/UPDATE/DELETE
- Extract Graph: LLM extracts entities and relationships
- Store: Save to Postgres (L2), Milvus (vector), FalkorDB (graph), Redis (L1)
Read Path
- Check Cache: Redis L1 for recent queries
- Parallel Search: Milvus (vector) + Postgres (fulltext) + FalkorDB (graph)
- Rank: RRF fusion + temporal decay scoring
- Return: Combined memories + relations
Temporal Decay
Memories decay exponentially over time:
score = base_score × e^(-λt)Where:
λ = ln(2) / halfLifeDayst = days since last access
Frequently accessed memories get a logarithmic boost.
License
Apache-2.0
