Skip to content

Latest commit

Β 

History

58 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⛓️ Adaptive Conversational Memory

An adaptive memory architecture for conversational AI that goes beyond traditional semantic retrieval by combining semantic, episodic, procedural, and temporal memory with hybrid retrieval, adaptive reranking, conflict resolution, consolidation, lifecycle management, and controlled forgetting.

Python Tests Benchmark Recall@5 Baseline Recall@5


πŸ“Œ Overview

Most Retrieval-Augmented Generation (RAG) systems treat retrieved information primarily as a collection of semantically similar documents.

That approach works well for static knowledge, but conversational AI requires something more sophisticated.

A user may have:

  • Current preferences
  • Previous preferences
  • Repeated behaviors
  • Past events
  • Procedural knowledge
  • Time-dependent information
  • Conflicting memories
  • Frequently accessed information
  • Information that should eventually be forgotten

For example:

"Which database do I currently prefer?"

A traditional semantic retriever may return both:

  • "I previously used MongoDB."
  • "I now prefer PostgreSQL."

Both statements are semantically relevant, but only one represents the user's current preference.

This project addresses that problem by introducing an Adaptive Conversational Memory Architecture that dynamically routes queries, retrieves memories from multiple memory systems, fuses candidates, reranks them using multiple signals, resolves conflicts, builds context, and finally generates a response.


🎯 Project Objective

The primary objective is to design a conversational memory system capable of:

  1. Understanding different types of memories.
  2. Storing memories using appropriate representations.
  3. Routing queries to the most relevant memory subsystem.
  4. Combining results from multiple retrieval mechanisms.
  5. Ranking memories using more than semantic similarity.
  6. Handling conflicting and outdated information.
  7. Consolidating repeated information.
  8. Managing memory lifecycle and controlled forgetting.
  9. Building relevant conversational context.
  10. Evaluating retrieval quality against a baseline system.

πŸ—οΈ System Architecture

Memory Ingestion Flow

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   User Conversation  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Memory Extraction  β”‚
                         β”‚      using LLM       β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚  Memory Classifier   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                     β”‚                     β”‚
              β–Ό                     β–Ό                     β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚  Semantic   β”‚       β”‚  Episodic   β”‚       β”‚ Procedural  β”‚
       β”‚   Memory    β”‚       β”‚   Memory    β”‚       β”‚   Memory    β”‚
       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
              β”‚                     β”‚                     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Importance /         β”‚
                         β”‚ Confidence Scoring   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Conflict Detection   β”‚
                         β”‚ & Resolution         β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Memory Consolidation β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚          Memory Storage         β”‚
                    β”‚                                 β”‚
                    β”‚ Vector β”‚ Temporal β”‚ Graph/Proc β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Memory Lifecycle     β”‚
                         β”‚ & Controlled Forget. β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”Ž Adaptive Retrieval Architecture

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚      User Query      β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚    Memory Router     β”‚
                         β”‚                      β”‚
                         β”‚ Semantic             β”‚
                         β”‚ Episodic             β”‚
                         β”‚ Procedural            β”‚
                         β”‚ Temporal              β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚          Memory-Specific Retrieval       β”‚
               β”‚                                          β”‚
               β”‚ Vector Retrieval                         β”‚
               β”‚ Temporal Retrieval                       β”‚
               β”‚ Graph Retrieval                          β”‚
               β”‚ Procedural Retrieval                     β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Candidate Fusion   β”‚
                         β”‚                      β”‚
                         β”‚ Deduplication        β”‚
                         β”‚ Score Normalization   β”‚
                         β”‚ Hybrid Fusion         β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Adaptive Reranker    β”‚
                         β”‚                      β”‚
                         β”‚ Retrieval Score      β”‚
                         β”‚ Query Relevance      β”‚
                         β”‚ Importance            β”‚
                         β”‚ Recency               β”‚
                         β”‚ Source Priority       β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Conflict Detection   β”‚
                         β”‚ & Resolution         β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚    Context Builder   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚  Response Generator  β”‚
                         β”‚        + LLM         β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Final Response     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧩 Core System Components

1. Memory Extraction

Conversational information is extracted into structured memory representations.

Examples:

"I prefer PostgreSQL now."
"I previously used MongoDB."
"I worked on an AI project yesterday."
"My usual deployment process involves..."

The extracted information is converted into structured memory objects.


2. Memory Classification

The system classifies memories according to their role.

Semantic Memory

Stable facts, preferences, interests, and knowledge.

Example:

I prefer Python for machine learning projects.

Episodic Memory

Past events and experiences.

Example:

Yesterday I worked on my adaptive conversational memory project.

Procedural Memory

Knowledge about how the user performs tasks.

Example:

I first implement the experiment, then run its tests,
and finally run the complete pytest suite.

Temporal Memory

Information whose relevance depends strongly on time.

Example:

I currently use Go.
I previously used Python.

3. Memory Router

The Memory Router analyzes the query and determines which memory subsystem should be prioritized.

Examples:

"What did I work on yesterday?"
        ↓
     Episodic

"How do I deploy my application?"
        ↓
    Procedural

"What database do I currently prefer?"
        ↓
     Semantic
     + Temporal signals

4. Vector Memory

Semantic memories are represented using embeddings and stored in a vector store.

The vector retrieval system provides the initial semantic candidate set.

This is useful for queries where meaning is more important than exact keyword matching.


5. Temporal Memory

Temporal information is handled separately so that the system can distinguish between:

Previous preference
        ↓
Current preference
        ↓
Future / latest information

This prevents older memories from being treated as equally relevant when the user explicitly asks about current or recent information.


6. Graph-Based Memory

Graph structures allow relationships between memories, entities, and procedural states to be represented explicitly.

This is particularly useful when the relationship between pieces of information matters rather than just their semantic similarity.


7. Hybrid Retrieval

Instead of relying on a single retrieval mechanism, candidate results from different sources are combined.

The hybrid retrieval layer performs:

Multiple Retrieval Sources
          ↓
     Deduplication
          ↓
   Score Normalization
          ↓
     Score Fusion
          ↓
   Candidate Ranking

This creates a larger candidate pool for the adaptive reranker.


8. Adaptive Reranking

The reranker is one of the key components of the system.

Instead of ranking memories purely according to retrieval similarity, the system considers multiple signals:

Final Score =
    Retrieval Relevance
  + Query Relevance
  + Importance
  + Recency
  + Source Priority

Current deterministic ranking configuration:

Signal Weight
Retrieval Score 0.55
Query Relevance 0.15
Importance 0.12
Recency 0.10
Source Priority 0.08

This allows a memory with slightly lower embedding similarity to outrank a less useful memory when other signals indicate that it is more relevant.


9. Conflict Detection & Resolution

Conversational memory naturally contains contradictions.

Example:

Old:
I use MongoDB.

New:
I now prefer PostgreSQL.

The system identifies memories belonging to the same conflict group and resolves the conflict while preserving historical information.

The goal is not to simply delete the old memory.

Instead:

Historical Memory
       +
Current Memory
       ↓
Conflict Resolution
       ↓
Current preference is prioritized
Historical information remains available

10. Memory Consolidation

Repeated information can be consolidated into stronger memory representations.

For example:

Python used in project A
Python used in project B
Python used in project C

can support the higher-level understanding:

Python is repeatedly used across my projects.

This reduces redundant memory representations while preserving useful information.


11. Memory Lifecycle

Memories are not treated as permanently static objects.

Conceptually:

Created
   ↓
Active
   ↓
Accessed / Updated
   ↓
Consolidated
   ↓
Potentially Forgotten

The system also contains forgetting mechanisms for controlled memory management.


12. Context Building

After retrieval and reranking, the most relevant memories are converted into a context representation.

Retrieved Memories
       ↓
Ranked Memories
       ↓
Conflict Resolution
       ↓
Context Builder
       ↓
LLM Context

This prevents irrelevant memories from unnecessarily occupying the model's context.


13. Response Generation

The final context is passed to the response-generation layer.

User Query
     +
Relevant Memory Context
     ↓
     LLM
     ↓
Final Response

🧠 Why This Architecture?

Traditional semantic RAG:

Query
 ↓
Embedding
 ↓
Vector Search
 ↓
Top-K Documents
 ↓
LLM

Adaptive Conversational Memory:

Query
 ↓
Memory Routing
 ↓
Multiple Memory Systems
 ↓
Hybrid Retrieval
 ↓
Candidate Fusion
 ↓
Adaptive Reranking
 ↓
Conflict Resolution
 ↓
Context Construction
 ↓
LLM

The adaptive architecture provides additional mechanisms for:

  • Changing preferences
  • Historical information
  • Procedural knowledge
  • Time-sensitive memories
  • Conflicting memories
  • Repeated information
  • Memory importance
  • Memory recency
  • Memory lifecycle

πŸ“Š Evaluation

The system includes a dedicated retrieval benchmark containing 20 evaluation cases covering:

  • Semantic retrieval
  • Episodic retrieval
  • Procedural retrieval
  • Temporal retrieval
  • Conflict handling
  • Consolidation
  • Noise
  • Mixed queries

The adaptive retriever is evaluated against a baseline retriever.

Final Benchmark Results

Metric Baseline Adaptive Improvement
Recall@5 0.800 1.000 +25.00%
Precision@5 0.160 0.232 +44.79%
Hit@5 0.800 1.000 +25.00%
MRR 0.545 0.674 +23.70%
NDCG@5 0.608 0.754 +24.02%

Key Result

Adaptive Recall@5 improved from 0.800 to 1.000, achieving a 25% relative improvement over the baseline.

The adaptive system achieved 1.000 Recall@5 and 1.000 Hit@5 across all 20 benchmark cases.


πŸ§ͺ Testing

The project contains a comprehensive automated test suite covering the major system components.

Final validation:

507 / 507 tests passed

The complete retrieval benchmark was validated with:

20 / 20 cases

Validation flow:

Unit Tests
    ↓
Component Tests
    ↓
Memory Pipeline Tests
    ↓
Retrieval Benchmark

πŸ“ˆ Benchmark Interpretation

Recall@5

Baseline   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘  0.800
Adaptive   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  1.000

Hit@5

Baseline   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘  0.800
Adaptive   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  1.000

NDCG@5

Baseline   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘  0.608
Adaptive   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘  0.754

The improvement is not limited to whether the correct memory appears in the retrieved set. MRR and NDCG also improve, indicating better ranking quality.


πŸ—‚οΈ Project Structure

Adaptive-Conversational-Memory/
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ conversations/
β”‚   β”œβ”€β”€ evaluation/
β”‚   └── memories/
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ populate_graph_store.py
β”‚   β”œβ”€β”€ populate_temporal_store.py
β”‚   β”œβ”€β”€ populate_vector_store.py
β”‚   └── run_benchmark.py
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ classification/
β”‚   β”œβ”€β”€ conflict/
β”‚   β”œβ”€β”€ consolidation/
β”‚   β”œβ”€β”€ embeddings/
β”‚   β”œβ”€β”€ evaluation/
β”‚   β”œβ”€β”€ forgetting/
β”‚   β”œβ”€β”€ lifecycle/
β”‚   β”œβ”€β”€ llm/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ pipeline/
β”‚   β”œβ”€β”€ retrieval/
β”‚   β”œβ”€β”€ routing/
β”‚   └── storage/
β”‚
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_adaptive_memory.py
β”‚   β”œβ”€β”€ test_adaptive_retriever.py
β”‚   β”œβ”€β”€ test_baseline_rag.py
β”‚   β”œβ”€β”€ test_conflict.py
β”‚   β”œβ”€β”€ test_consolidation.py
β”‚   β”œβ”€β”€ test_forgetting.py
β”‚   β”œβ”€β”€ test_hybrid_retriever.py
β”‚   β”œβ”€β”€ test_memory_pipeline.py
β”‚   β”œβ”€β”€ test_reranker.py
β”‚   β”œβ”€β”€ test_router.py
β”‚   └── ...
β”‚
β”œβ”€β”€ requirements.txt
└── README.md

βš™οΈ Installation

Clone the repository

git clone <your-repository-url>
cd Adaptive-Conversational-Memory

Create a virtual environment

python -m venv .venv

macOS / Linux

source .venv/bin/activate

Windows

.venv\Scripts\activate

Install dependencies

pip install -r requirements.txt

πŸš€ Running the Project

Run the complete test suite

python -m pytest

Expected:

507 passed

Run the retrieval benchmark

PYTHONPATH=. python scripts/run_benchmark.py

The benchmark compares the baseline retrieval system against the adaptive retrieval system.


πŸ“Š Evaluation Metrics

Recall@K

Measures how many relevant memories are retrieved within the top K results.

Precision@K

Measures the proportion of retrieved results that are relevant.

Hit@K

Measures whether at least one relevant memory appears in the top K.

Mean Reciprocal Rank (MRR)

Measures how highly the first relevant memory is ranked.

NDCG@K

Measures ranking quality while considering the position of relevant results.


πŸ”¬ Design Principles

1. Memory is heterogeneous

Not every memory should be represented or retrieved in the same way.

2. Relevance is multidimensional

Semantic similarity alone is insufficient.

3. Time matters

A recent preference may be more relevant than an older conflicting preference.

4. Conflicts should be resolved, not blindly deleted

Historical information can remain useful.

5. Retrieval should be adaptive

Different queries require different memory strategies.

6. Memory requires lifecycle management

Memories should be created, accessed, updated, consolidated, and potentially forgotten.

7. Retrieval should be measurable

The system includes an explicit evaluation framework rather than relying only on qualitative examples.


πŸ› οΈ Technology Stack

Language
    Python

AI / ML
    Sentence Embeddings
    Hugging Face Models
    LLM-based Memory Extraction
    LLM-based Response Generation

Retrieval
    Vector Retrieval
    Hybrid Retrieval
    Graph Retrieval
    Temporal Retrieval
    Adaptive Reranking

Storage
    Vector Store
    Temporal Store
    Graph Store
    SQLite-based Memory Storage

Evaluation
    Pytest
    Recall@K
    Precision@K
    Hit@K
    MRR
    NDCG

πŸŽ“ Project Highlights

This project demonstrates practical implementation of:

  • Conversational AI memory architectures
  • Retrieval-Augmented Generation
  • Semantic search
  • Hybrid retrieval
  • Embedding-based retrieval
  • Query routing
  • Reranking
  • Temporal reasoning
  • Conflict resolution
  • Memory consolidation
  • Controlled forgetting
  • Graph-based memory
  • Evaluation-driven development
  • End-to-end AI pipeline design

πŸ’‘ Example

Consider the following memories:

Memory 1:
I previously used MongoDB.

Memory 2:
I now prefer PostgreSQL.

Memory 3:
I usually use PostgreSQL for relational projects.

Query:

Which database do I currently prefer?

Instead of simply returning the most semantically similar memories, the adaptive system considers:

Semantic relevance
        +
Query relevance
        +
Importance
        +
Recency
        +
Memory source
        +
Conflict resolution

The system can therefore prioritize the current preference while preserving the historical memory.


🧠 Adaptive vs Traditional Retrieval

Capability Traditional Semantic RAG Adaptive Conversational Memory
Semantic retrieval βœ… βœ…
Multiple memory types ❌ βœ…
Query routing ❌ βœ…
Temporal retrieval Limited βœ…
Procedural memory Limited βœ…
Graph memory Limited βœ…
Hybrid retrieval Limited βœ…
Adaptive reranking Limited βœ…
Importance scoring ❌ βœ…
Recency scoring ❌ βœ…
Conflict resolution ❌ βœ…
Memory consolidation ❌ βœ…
Controlled forgetting ❌ βœ…
Retrieval benchmark Varies βœ…

πŸ“Œ Current Status

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        ADAPTIVE MEMORY PROJECT             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                            β”‚
β”‚  Memory Architecture       βœ… Complete     β”‚
β”‚  Query Routing             βœ… Complete     β”‚
β”‚  Hybrid Retrieval          βœ… Complete     β”‚
β”‚  Adaptive Reranking        βœ… Complete     β”‚
β”‚  Conflict Resolution       βœ… Complete     β”‚
β”‚  Memory Consolidation      βœ… Complete     β”‚
β”‚  Memory Lifecycle          βœ… Complete     β”‚
β”‚  Controlled Forgetting     βœ… Complete     β”‚
β”‚  End-to-End Pipeline       βœ… Validated    β”‚
β”‚  Automated Tests           βœ… 507/507      β”‚
β”‚  Benchmark                 βœ… 20/20        β”‚
β”‚  Adaptive Recall@5         βœ… 1.000        β”‚
β”‚                                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ˆ Final Result

Baseline Recall@5
        0.800
          β”‚
          β”‚ +25%
          β–Ό
Adaptive Recall@5
        1.000

Additional improvements:

Precision@5   0.160 β†’ 0.232
Hit@5         0.800 β†’ 1.000
MRR           0.545 β†’ 0.674
NDCG@5        0.608 β†’ 0.754

The benchmark demonstrates measurable improvement in both retrieval coverage and ranking quality.


🚧 Future Improvements

Potential future extensions include:

  • Learned reranking models
  • Neural conflict resolution
  • Larger conversational datasets
  • Online memory learning
  • User-specific memory policies
  • More advanced temporal reasoning
  • Long-term memory compression
  • Reinforcement-based retrieval optimization
  • Multi-user memory isolation
  • Distributed memory storage
  • Production-scale vector and graph infrastructure
  • Large-scale evaluation across real conversational datasets

πŸ“œ License

This project is intended for academic and research purposes.

Add your preferred license here if the repository will be publicly distributed.


⭐ Summary

Adaptive Conversational Memory is a multi-layer memory architecture designed to make conversational AI systems more reliable when dealing with persistent, changing, temporal, procedural, and conflicting user information.

Rather than treating memory as a simple vector database, the system combines:

Memory Classification
        ↓
Memory Routing
        ↓
Specialized Retrieval
        ↓
Hybrid Fusion
        ↓
Adaptive Reranking
        ↓
Conflict Resolution
        ↓
Context Construction
        ↓
LLM Response Generation
        ↓
Memory Lifecycle Management

With a final benchmark result of:

Recall@5: 1.000 vs 0.800 baseline

and:

507/507 automated tests passing

the project provides an evaluation-driven implementation of an adaptive conversational memory architecture.

About

Adaptive memory architecture for LLM-powered conversational AI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages