vmore2/AgentRank-base

7

stars

3

commits

Python

primary language

Dec 28, 2025

updated

README

🧠 AgentRank

Temporal-aware embeddings for AI agent memory retrieval.

PyPI version License HuggingFace


The Problem

Standard embedding models (OpenAI, Cohere, MiniLM) treat "yesterday" and "6 months ago" identically. For AI agents with long-term memory, this breaks temporal reasoning completely.

AgentRank solves this with embeddings that understand:

  • When memories happened (temporal awareness)
  • 📂 What type of memory it is (episodic, semantic, procedural)
  • 21% better retrieval on agent memory benchmarks

Installation

pip install agentrank

Quick Start

from agentrank import AgentRankEmbedder

# Load model
model = AgentRankEmbedder.from_pretrained("vrushket/agentrank-base")

# Encode with temporal context
embeddings = model.encode(
    texts=["User prefers Python for backend development"],
    temporal_info=[7],        # 7 days ago
    memory_types=["semantic"] # It's a preference
)

# Use embeddings for retrieval
print(embeddings.shape)  # [1, 768]

Model Family

ModelTypeParamsUse CaseHuggingFace
AgentRank-BaseEmbedder149MBest quality retrievalvrushket/agentrank-base
AgentRank-SmallEmbedder33MFast inferencevrushket/agentrank-small
AgentRank-RerankerCross-encoder149MAccurate rerankingvrushket/agentrank-reranker

Two-Stage Retrieval Pipeline

For best results, use a two-stage pipeline:

from agentrank import AgentRankEmbedder
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

# Stage 1: Fast retrieval with embedder
embedder = AgentRankEmbedder.from_pretrained("vrushket/agentrank-base")
query_embedding = embedder.encode(["What's my Python preference?"])
# ... search vector DB → get top-50 candidates ...

# Stage 2: Accurate reranking with cross-encoder
reranker = AutoModelForSequenceClassification.from_pretrained("vrushket/agentrank-reranker")
tokenizer = AutoTokenizer.from_pretrained("vrushket/agentrank-reranker")

def rerank(query, candidates, top_k=10):
    scored = []
    for memory in candidates:
        inputs = tokenizer(query, memory, return_tensors="pt", truncation=True)
        with torch.no_grad():
            score = torch.sigmoid(reranker(**inputs).logits).item()
        scored.append((score, memory))
    return sorted(scored, reverse=True)[:top_k]

top_10 = rerank("What's my Python preference?", top_50_candidates)

Benchmarks

ModelMRRRecall@1Recall@5NDCG@10
AgentRank-Base0.64960.444099.6%0.6786
AgentRank-Small0.63750.446097.4%0.6797
MPNet-base-v20.53510.366079.6%0.6335
MiniLM-L6-v20.52970.372075.2%0.6370

+22% MRR improvement over baseline embedding models.

RerankerValidation AccuracyVal Loss
AgentRank-Reranker89.11%0.2554

Key Features

Temporal Embeddings

10 learnable time buckets encode recency:

  • Today/Yesterday, This Week, This Month, Last Quarter, etc.
  • Model learns what "recent" means in context

Memory Type Embeddings

Distinguish between:

  • Episodic: Events ("We discussed Python yesterday")
  • Semantic: Facts/preferences ("User likes Python")
  • Procedural: Instructions ("To deploy, run npm build")

Architecture

  • Base: ModernBERT-base / MiniLM
  • Temporal + Type embeddings added (scaled by 0.1)
  • Trained on 500K synthetic agent memory samples
  • Hard negative mining with 7 negative types

Works Great With

CogniHive — Multi-agent memory with "who knows what" routing

pip install cognihive

Together: CogniHive routes questions to the right agent, AgentRank retrieves the right memories.



Contact


License

Apache 2.0 — Free for commercial use.

Contributors

vmore2

3 commits

vmore2/AgentRank-base

7

stars

3

commits

Python

primary language

Dec 28, 2025

updated

README

🧠 AgentRank

Temporal-aware embeddings for AI agent memory retrieval.

PyPI version License HuggingFace


The Problem

Standard embedding models (OpenAI, Cohere, MiniLM) treat "yesterday" and "6 months ago" identically. For AI agents with long-term memory, this breaks temporal reasoning completely.

AgentRank solves this with embeddings that understand:

  • When memories happened (temporal awareness)
  • 📂 What type of memory it is (episodic, semantic, procedural)
  • 21% better retrieval on agent memory benchmarks

Installation

pip install agentrank

Quick Start

from agentrank import AgentRankEmbedder

# Load model
model = AgentRankEmbedder.from_pretrained("vrushket/agentrank-base")

# Encode with temporal context
embeddings = model.encode(
    texts=["User prefers Python for backend development"],
    temporal_info=[7],        # 7 days ago
    memory_types=["semantic"] # It's a preference
)

# Use embeddings for retrieval
print(embeddings.shape)  # [1, 768]

Model Family

ModelTypeParamsUse CaseHuggingFace
AgentRank-BaseEmbedder149MBest quality retrievalvrushket/agentrank-base
AgentRank-SmallEmbedder33MFast inferencevrushket/agentrank-small
AgentRank-RerankerCross-encoder149MAccurate rerankingvrushket/agentrank-reranker

Two-Stage Retrieval Pipeline

For best results, use a two-stage pipeline:

from agentrank import AgentRankEmbedder
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

# Stage 1: Fast retrieval with embedder
embedder = AgentRankEmbedder.from_pretrained("vrushket/agentrank-base")
query_embedding = embedder.encode(["What's my Python preference?"])
# ... search vector DB → get top-50 candidates ...

# Stage 2: Accurate reranking with cross-encoder
reranker = AutoModelForSequenceClassification.from_pretrained("vrushket/agentrank-reranker")
tokenizer = AutoTokenizer.from_pretrained("vrushket/agentrank-reranker")

def rerank(query, candidates, top_k=10):
    scored = []
    for memory in candidates:
        inputs = tokenizer(query, memory, return_tensors="pt", truncation=True)
        with torch.no_grad():
            score = torch.sigmoid(reranker(**inputs).logits).item()
        scored.append((score, memory))
    return sorted(scored, reverse=True)[:top_k]

top_10 = rerank("What's my Python preference?", top_50_candidates)

Benchmarks

ModelMRRRecall@1Recall@5NDCG@10
AgentRank-Base0.64960.444099.6%0.6786
AgentRank-Small0.63750.446097.4%0.6797
MPNet-base-v20.53510.366079.6%0.6335
MiniLM-L6-v20.52970.372075.2%0.6370

+22% MRR improvement over baseline embedding models.

RerankerValidation AccuracyVal Loss
AgentRank-Reranker89.11%0.2554

Key Features

Temporal Embeddings

10 learnable time buckets encode recency:

  • Today/Yesterday, This Week, This Month, Last Quarter, etc.
  • Model learns what "recent" means in context

Memory Type Embeddings

Distinguish between:

  • Episodic: Events ("We discussed Python yesterday")
  • Semantic: Facts/preferences ("User likes Python")
  • Procedural: Instructions ("To deploy, run npm build")

Architecture

  • Base: ModernBERT-base / MiniLM
  • Temporal + Type embeddings added (scaled by 0.1)
  • Trained on 500K synthetic agent memory samples
  • Hard negative mining with 7 negative types

Works Great With

CogniHive — Multi-agent memory with "who knows what" routing

pip install cognihive

Together: CogniHive routes questions to the right agent, AgentRank retrieves the right memories.



Contact


License

Apache 2.0 — Free for commercial use.

Contributors

vmore2

3 commits

Languages

Python

100.0%