AgentRank-Base is an embedding model designed for AI agents that need to remember. Unlike generic embedders (OpenAI, Cohere, MiniLM), AgentRank understands:
⏰ When something happened (temporal awareness)
📁 What type of memory it is (episodic vs semantic vs procedural)
⭐ How important the memory is
💡 Why AgentRank?
The Problem with Current Embedders
AI agents need memory. But when you ask an agent:
"What did we discuss about Python yesterday?"
Current embedders fail because they:
❌ Don't understand "yesterday" means recent time
❌ Can't distinguish between a preference and an event
❌ Treat all memories as equally important
The AgentRank Solution
Challenge
OpenAI/Cohere/MiniLM
AgentRank
"What did I say yesterday?"
Random old results 😕
Recent memories first ✅
"What's my preference?"
Mixed with events 😕
Only preferences ✅
"What's most important?"
No priority 😕
Importance-aware retrieval ✅
📊 Benchmarks
Evaluated on AgentMemBench (500 test samples, 8 candidates each):
Model
Parameters
MRR ↑
Recall@1 ↑
Recall@5 ↑
NDCG@10 ↑
AgentRank-Base
149M
0.6496
0.4440
0.9960
0.6786
AgentRank-Small
33M
0.6375
0.4460
0.9740
0.6797
all-mpnet-base-v2
109M
0.5351
0.3660
0.7960
0.6335
all-MiniLM-L6-v2
22M
0.5297
0.3720
0.7520
0.6370
Improvement Over Baselines
vs Baseline
MRR
Recall@1
Recall@5
vs MiniLM
+22.6%
+19.4%
+32.4%
vs MPNet
+21.4%
+21.3%
+25.1%
🚀 Quick Start
Installation
pip install transformers torch
Basic Usage
python
1from transformers import AutoModel, AutoTokenizer
2import torch
34# Load model and tokenizer5model = AutoModel.from_pretrained("vrushket/agentrank-base")6tokenizer = AutoTokenizer.from_pretrained("vrushket/agentrank-base")78defencode(texts, model, tokenizer):9"""Encode texts to embeddings."""10 inputs = tokenizer(11 texts,12 padding=True,13 truncation=True,14 max_length=512,15 return_tensors="pt"16)17with torch.no_grad():18 outputs = model(**inputs)19# Mean pooling20 embeddings = outputs.last_hidden_state.mean(dim=1)21# L2 normalize22 embeddings = torch.nn.functional.normalize(embeddings, p=2, dim=1)23return embeddings
2425# Your agent's memories26memories =[27"User prefers Python over JavaScript for backend development",28"User asked about React frameworks yesterday",29"User mentioned they have 3 years of coding experience",30"User is working on an e-commerce project",31]3233# A query from the user34query ="What programming language does the user prefer?"3536# Encode everything37memory_embeddings = encode(memories, model, tokenizer)38query_embedding = encode([query], model, tokenizer)3940# Find most similar memory41similarities = torch.mm(query_embedding, memory_embeddings.T)[0]42best_match_idx = similarities.argmax().item()4344print(f"Query: {query}")45print(f"Best match: {memories[best_match_idx]}")46print(f"Similarity: {similarities[best_match_idx]:.4f}")4748# Output:49# Query: What programming language does the user prefer?50# Best match: User prefers Python over JavaScript for backend development51# Similarity: 0.8234
Advanced Usage with Metadata
For full temporal and memory type awareness, use the AgentRank package:
python
1# Coming soon: pip install agentrank2from agentrank import AgentRankEmbedder
34model = AgentRankEmbedder.from_pretrained("vrushket/agentrank-base")56# Encode with temporal context7memory_embedding = model.encode(8 text="User mentioned they prefer morning meetings",9 days_ago=7,# Memory is 1 week old10 memory_type="semantic"# It's a preference (not an event)11)1213# Encode query (no metadata needed for queries)14query_embedding = model.encode("When does the user like to have meetings?")1516# The model now knows this is a week-old preference!17similarity = torch.cosine_similarity(query_embedding, memory_embedding, dim=0)
🔧 Architecture
AgentRank-Base is built on ModernBERT-base (110M params) with novel additions:
Encodes memory age (today, this week, last month, etc.)
"Yesterday" queries match recent memories
Memory Type Embeddings
Distinguishes episodic/semantic/procedural
"What do I like?" matches preferences, not events
Importance Head
Auxiliary task predicting memory priority
Helps learn better representations
Temporal Buckets
Bucket 0: Today (0-1 days)
Bucket 1: Recent (1-3 days)
Bucket 2: This week (3-7 days)
Bucket 3: Last week (7-14 days)
Bucket 4: This month (14-30 days)
Bucket 5: Last month (30-60 days)
Bucket 6: Few months (60-90 days)
Bucket 7: Half year (90-180 days)
Bucket 8: This year (180-365 days)
Bucket 9: Long ago (365+ days)
Memory Types
Type 0: Episodic → Events, conversations ("We discussed X yesterday")
Type 1: Semantic → Facts, preferences ("User likes Python")
Type 2: Procedural → Instructions ("To deploy, run npm build")
Type 3: Unknown → Fallback
🎓 Training Details
Aspect
Details
Base Model
answerdotai/ModernBERT-base (110M params)
Training Data
500K synthetic agent memory samples
Memory Distribution
Episodic (40%), Semantic (35%), Procedural (25%)
Loss Function
Multiple Negatives Ranking Loss + Importance MSE
Hard Negatives
7 per sample (5 types: temporal, type confusion, topic drift, etc.)
Batch Size
16-32 per GPU
Hardware
2× NVIDIA RTX 6000 Ada (48GB each)
Training Time
~12 hours
Precision
FP16 Mixed Precision
Final Val Loss
0.877
🏗️ Use Cases
1. AI Agents with Long-Term Memory
python
1# Store memories with metadata2agent.remember(3 text="User is allergic to peanuts",4 memory_type="semantic",5 importance=10,# Critical medical info!6)78# Later, when discussing food...9relevant_memories = agent.recall("What should I know about the user's diet?")10# Returns: "User is allergic to peanuts" (even if stored months ago)
2. RAG Systems for Conversational AI
python
1# Better retrieval for chatbots2query ="What did we talk about in our last meeting?"3# AgentRank returns recent, relevant conversations4# Generic embedders return random topically-similar docs
3. Personal Knowledge Bases
python
1# User's notes and preferences2memories =[3"I prefer dark mode in all apps",4"My morning routine starts at 6 AM",5"Important: Tax deadline April 15",6]7# AgentRank properly handles time-sensitive queries