Downloads · 30 days
73
25% of all-time downloads
vrushket/agentrank-small
agentrank-small is a sentence similarity model from vrushket. Use it when you need a score for how close two texts are. It is set up for transformers. The card lists the license as apache-2.0.
<p align="center" <img src="https://img.shields.io/badge/MRR-0.6375-brightgreen" alt="MRR" <img src="https://img.shields.io/badge/Recall%405-97.4%25-blue" alt="Recall@5" <img src="https://img.shields.io/badge/Paramete…
Downloads · 30 days
73
25% of all-time downloads
All-time downloads
293
Public
Parameters
22.7M
91.8 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors90.9 MB · 98%
From the Hugging Face model README
AgentRank is the first embedding model family specifically designed for AI agent memory retrieval. Unlike general-purpose embedders, AgentRank understands temporal context, memory types, and importance - critical for agents that need to remember past interactions.
| Model | MRR | Recall@1 | Recall@5 | NDCG@10 |
|---|---|---|---|---|
| AgentRank-Small | 0.6375 | 0.4460 | 0.9740 | 0.6797 |
| all-MiniLM-L6-v2 | 0.5297 | 0.3720 | 0.7520 | 0.6370 |
| all-mpnet-base-v2 | 0.5351 | 0.3660 | 0.7960 | 0.6335 |
+20% MRR improvement over base MiniLM model!
AI agents need memory that understands:
| Challenge | General Embedders | AgentRank |
|---|---|---|
| "What did I say yesterday?" | ❌ No temporal awareness | ✅ Temporal embeddings |
| "What's my preference?" | ❌ Mixes with events | ✅ Memory type awareness |
| "What's most important?" | ❌ No priority | ✅ Importance prediction |
pip install transformers torch
from transformers import AutoModel, AutoTokenizer
import torch
# Load model
model = AutoModel.from_pretrained("vrushket/agentrank-small")
tokenizer = AutoTokenizer.from_pretrained("vrushket/agentrank-small")
def encode(texts):
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
embeddings = outputs.last_hidden_state.mean(dim=1)
embeddings = torch.nn.functional.normalize(embeddings, p=2, dim=1)
return embeddings
# Encode memories and query
memories = [
"User prefers Python over JavaScript",
"User asked about machine learning yesterday",
"User is working on a web project",
]
query = "What programming language does the user like?"
memory_embeddings = encode(memories)
query_embedding = encode([query])
# Compute similarities
similarities = torch.mm(query_embedding, memory_embeddings.T)
print(f"Most relevant: {memories[similarities.argmax()]}")
# Output: "User prefers Python over JavaScript"
# For full AgentRank features including temporal awareness:
# pip install agentrank (coming soon!)
from agentrank import AgentRankEmbedder
model = AgentRankEmbedder.from_pretrained("vrushket/agentrank-small")
# Encode with metadata
embedding = model.encode(
"User mentioned they prefer morning meetings",
days_ago=3, # Memory is 3 days old
memory_type="semantic" # It's a preference, not an event
)
AgentRank-Small is based on all-MiniLM-L6-v2 with novel additions:
┌─────────────────────────────────────────┐
│ MiniLM Transformer Encoder (6 layers) │
└─────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
↓ ↓ ↓
┌─────────┐ ┌──────────┐ ┌───────────┐
│ Temporal │ │ Memory │ │ Importance│
│ Position │ │ Type │ │ Prediction│
│ Embed │ │ Embed │ │ Head │
└─────────┘ └──────────┘ └───────────┘
│ │ │
└───────────────┼───────────────┘
↓
┌─────────────────┐
│ L2 Normalized │
│ 384-dim Embedding│
└─────────────────┘
Novel Features:
Evaluated on AgentMemBench (500 test samples, 8 candidates each):
| Metric | AgentRank-Small | MiniLM | Improvement |
|---|---|---|---|
| MRR | 0.6375 | 0.5297 | +20.4% |
| Recall@1 | 0.4460 | 0.3720 | +19.9% |
| Recall@5 | 0.9740 | 0.7520 | +29.5% |
| NDCG@10 | 0.6797 | 0.6370 | +6.7% |
pip install agentrank@misc{agentrank2024,
author = {Vrushket More},
title = {AgentRank: Embedding Models for AI Agent Memory Retrieval},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/vrushket/agentrank-small}
}
Apache 2.0 - Free for commercial use!
Built on top of sentence-transformers and MiniLM.