RankifyAgent API
Intelligent model recommendation system for Rankify.
Overview
RankifyAgent provides:
- Programmatic recommendations via recommend() and RankifyRecommender
- Conversational interface via RankifyAgent class
- Model registry with metadata for all available models
Quick Example
from rankify.agent import recommend, RankifyAgent
# Quick recommendation
result = recommend(task="qa", gpu=True)
print(result.retriever.name) # "BGE"
# Conversational agent
agent = RankifyAgent(backend="azure")
response = agent.chat("I need a fast search system")
print(response.message)
API Reference
rankify.agent
RankifyAgent - Intelligent Model Recommendation System for Rankify.
This module provides: - RankifyAgent: Conversational AI assistant for model selection - RankifyRecommender: Programmatic recommendation API - Model Registry: Metadata for all available models
Example Usage
from rankify.agent import RankifyAgent, recommend
# Quick recommendation
result = recommend(task="qa", gpu=True)
print(result.retriever.name)
print(result.reranker.name)
# Conversational interface
agent = RankifyAgent(backend="azure")
response = agent.chat("I need a fast search system for production")
print(response.message)
print(response.code_snippet)
RETRIEVER_REGISTRY = {'bm25': ModelMetadata(name='BM25', method='bm25', description='Classic sparse retrieval using BM25 algorithm. Fast, no GPU needed.', speed=(Speed.VERY_FAST), accuracy=(Accuracy.GOOD), gpu_required=False, memory_mb=500, best_for=['keyword search', 'exact match', 'large corpus', 'low latency'], languages=['en', 'multilingual']), 'dpr-multi': ModelMetadata(name='DPR (Multi-Encoder)', method='dpr', description='Dense Passage Retrieval with separate query/passage encoders.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=2000, best_for=['semantic search', 'qa', 'open-domain qa'], model_path='facebook-dpr-ctx_encoder-multiset-base'), 'dpr-single': ModelMetadata(name='DPR (Single-Encoder)', method='dpr', description='DPR with single encoder for both query and passage.', speed=(Speed.FAST), accuracy=(Accuracy.GOOD), gpu_required=True, memory_mb=1500, best_for=['semantic search', 'faster inference'], model_path='facebook-dpr-question_encoder-single-nq-base'), 'ance': ModelMetadata(name='ANCE', method='ance', description='Approximate Nearest Neighbor Negative Contrastive Estimation.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=2500, best_for=['high accuracy retrieval', 'qa', 'passage ranking'], model_path='castorini/ance-msmarco-passage'), 'bge': ModelMetadata(name='BGE', method='bge', description='BAAI General Embedding - state-of-the-art dense retriever.', speed=(Speed.FAST), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=1500, best_for=['semantic search', 'qa', 'high accuracy', 'multilingual'], languages=['en', 'zh', 'multilingual'], model_path='BAAI/bge-base-en-v1.5'), 'colbert': ModelMetadata(name='ColBERT', method='colbert', description='Contextualized Late Interaction over BERT - token-level matching.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=4000, best_for=['high precision', 'passage retrieval', 'fine-grained matching'], model_path='colbert-ir/colbertv2.0'), 'contriever': ModelMetadata(name='Contriever', method='contriever', description='Unsupervised dense retriever, good zero-shot performance.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=1800, best_for=['zero-shot retrieval', 'domain transfer', 'no training data'], model_path='facebook/contriever-msmarco'), 'hyde': ModelMetadata(name='HyDE (Hypothetical Document Embeddings)', method='hyde', description='Generates hypothetical documents to improve retrieval.', speed=(Speed.SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=3000, api_required=True, best_for=['complex queries', 'sparse training data', 'query expansion']), 'online': ModelMetadata(name='Online Retriever', method='online', description='Web search-based retrieval using search APIs.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=False, memory_mb=100, api_required=True, api_provider='serper', best_for=['real-time data', 'current events', 'web search']), 'diver-bge': ModelMetadata(name='Diver (BGE Large)', method='diver-dense', description='BAAI/bge-large-en-v1.5 via the Diver dense retrieval framework.', speed=(Speed.MEDIUM), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=3000, best_for=['semantic search', 'high accuracy', 'BEIR benchmarks'], model_path='bge'), 'diver-sbert': ModelMetadata(name='Diver (SBERT all-mpnet-base-v2)', method='diver-dense', description='sentence-transformers/all-mpnet-base-v2 via the Diver framework.', speed=(Speed.FAST), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=1500, best_for=['sentence similarity', 'semantic search'], model_path='sbert'), 'diver-nomic': ModelMetadata(name='Diver (Nomic Embed)', method='diver-dense', description='nomic-ai/nomic-embed-text-v1 via the Diver framework.', speed=(Speed.FAST), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=1500, best_for=['long context', 'semantic search', 'document retrieval'], model_path='nomic'), 'diver-e5': ModelMetadata(name='Diver (E5-Mistral-7B)', method='diver-dense', description='intfloat/e5-mistral-7b-instruct — instruction-tuned LLM encoder in the Diver framework.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=16000, best_for=['zero-shot retrieval', 'instruction following', 'complex queries'], model_path='e5'), 'diver-sf': ModelMetadata(name='Diver (SFR-Embedding-Mistral)', method='diver-dense', description='Salesforce/SFR-Embedding-Mistral — Salesforce Mistral-based bi-encoder in the Diver framework.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=16000, best_for=['high accuracy retrieval', 'complex queries', 'BEIR benchmarks'], model_path='sf'), 'diver-rader': ModelMetadata(name='Diver (RaDeR)', method='diver-dense', description='Raderspace/RaDeR_Qwen_25_7B — reasoning-aware dense retriever in the Diver framework.', speed=(Speed.SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=16000, best_for=['reasoning-intensive queries', 'multi-hop QA', 'math-related retrieval'], model_path='rader'), 'diver-grit': ModelMetadata(name='Diver (GritLM-7B)', method='diver-dense', description='GritLM/GritLM-7B — generative representation model in the Diver framework.', speed=(Speed.VERY_SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=16000, best_for=['generative retrieval', 'LLM-quality embeddings', 'long context'], model_path='grit'), 'diver-model': ModelMetadata(name='Diver Retriever-4B', method='diver-dense', description='AQ-MedAI/Diver-Retriever-4B — the flagship Diver diverse-evidence retrieval model.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=8000, best_for=['diverse evidence retrieval', 'BEIR benchmarks', 'medical QA'], model_path='diver'), 'diver-inst-l': ModelMetadata(name='Diver (Instructor-Large)', method='diver-dense', description='hkunlp/instructor-large — instruction-following encoder in the Diver framework.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=3000, best_for=['instruction following', 'domain-specific retrieval'], model_path='inst-l'), 'diver-m2': ModelMetadata(name='Diver (M2-BERT-32K)', method='diver-dense', description='togethercomputer/m2-bert-80M-32k-retrieval — long-context retrieval in the Diver framework.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=2000, best_for=['long-context retrieval', '32k sequence length'], model_path='m2'), 'reasonir': ModelMetadata(name='ReasonIR-8B', method='reasonir', description='reasonir/ReasonIR-8B — SOTA reasoning-intensive retriever on the BRIGHT benchmark. No model_id needed.', speed=(Speed.VERY_SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=16000, best_for=['reasoning-intensive queries', 'BRIGHT benchmark', 'complex multi-hop QA', 'science queries']), 'reason-embed-qwen3-8b': ModelMetadata(name='ReasonEmbed Qwen3-8B', method='reason-embed', description="hanhainebula/reason-embed-qwen3-8b-0928 — Qwen3-8B for reasoning retrieval. Use model_id='qwen3-8b'.", speed=(Speed.VERY_SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=16000, best_for=['reasoning-intensive retrieval', 'complex queries'], model_path='qwen3-8b'), 'reason-embed-qwen3-4b': ModelMetadata(name='ReasonEmbed Qwen3-4B', method='reason-embed', description="hanhainebula/reason-embed-qwen3-4b-0928 — balanced Qwen3-4B for reasoning retrieval. Use model_id='qwen3-4b'.", speed=(Speed.SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=8000, best_for=['reasoning retrieval', 'balanced accuracy/speed'], model_path='qwen3-4b'), 'reason-embed-llama-8b': ModelMetadata(name='ReasonEmbed LLaMA-3.1-8B', method='reason-embed', description="hanhainebula/reason-embed-llama-3.1-8b-0928 — LLaMA-3.1-8B for reasoning retrieval. Use model_id='llama-8b'.", speed=(Speed.SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=16000, best_for=['reasoning retrieval', 'open-source LLaMA backbone'], model_path='llama-8b'), 'bge-reasoner-embed': ModelMetadata(name='BGE Reasoner Embed (Qwen3-8B)', method='bge-reasoner-embed', description='BAAI/bge-reasoner-embed-qwen3-8b-0923 — BGE reasoning-augmented retriever. No model_id needed.', speed=(Speed.SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=16000, best_for=['reasoning-augmented retrieval', 'BEIR benchmarks', 'complex queries'])}
module-attribute
RERANKER_REGISTRY = {'monot5-base-msmarco': ModelMetadata(name='MonoT5 Base', method='monot5', description='T5-based pointwise reranker, trained on MS MARCO.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=900, best_for=['qa', 'general reranking', 'passage ranking'], model_path='castorini/monot5-base-msmarco'), 'monot5-3b-msmarco': ModelMetadata(name='MonoT5 3B', method='monot5', description='Large MonoT5 reranker for highest accuracy.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=12000, best_for=['highest accuracy', 'offline processing'], model_path='castorini/monot5-3b-msmarco'), 'monobert': ModelMetadata(name='MonoBERT', method='monobert', description='BERT-based pointwise reranker.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=1500, best_for=['qa', 'document ranking'], model_path='castorini/monobert-large-msmarco'), 'flashrank-minilm': ModelMetadata(name='FlashRank MiniLM', method='flashrank', description='Ultra-fast ONNX-based reranker, CPU-friendly.', speed=(Speed.VERY_FAST), accuracy=(Accuracy.GOOD), gpu_required=False, memory_mb=50, best_for=['low latency', 'cpu deployment', 'edge devices', 'production'], model_path='ms-marco-MiniLM-L-12-v2'), 'flashrank-tinybert': ModelMetadata(name='FlashRank TinyBERT', method='flashrank', description='Smallest FlashRank model, fastest inference.', speed=(Speed.VERY_FAST), accuracy=(Accuracy.BASIC), gpu_required=False, memory_mb=20, best_for=['ultra-low latency', 'mobile', 'embedded'], model_path='ms-marco-TinyBERT-L-2-v2'), 'upr-t5-base': ModelMetadata(name='UPR (T5 Base)', method='upr', description='Unsupervised Passage Reranker using T5.', speed=(Speed.MEDIUM), accuracy=(Accuracy.GOOD), gpu_required=True, memory_mb=900, best_for=['zero-shot reranking', 'no training data'], model_path='t5-base'), 'rankgpt-gpt4': ModelMetadata(name='RankGPT (GPT-4)', method='rankgpt-api', description='LLM-based listwise reranking using GPT-4.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=False, memory_mb=100, api_required=True, api_provider='openai', best_for=['highest accuracy', 'complex queries', 'reasoning-based ranking'], model_path='gpt-4o'), 'rankgpt-llama': ModelMetadata(name='RankGPT (LLaMA)', method='rankgpt', description='Local LLM-based listwise reranking using LLaMA.', speed=(Speed.VERY_SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=16000, best_for=['high accuracy', 'privacy', 'no api costs'], model_path='meta-llama/Meta-Llama-3.1-8B-Instruct'), 'inranker-base': ModelMetadata(name='InRanker Base', method='inranker', description='In-context reranking with instruction-tuned models.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=1500, best_for=['instruction following', 'zero-shot'], model_path='unicamp-dl/InRanker-base'), 'echorank': ModelMetadata(name='EchoRank', method='echorank', description='Pairwise reranking with echo-based verification.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=2000, best_for=['verification', 'fact checking']), 'rankt5-base': ModelMetadata(name='RankT5 Base', method='rankt5', description='T5-based listwise reranker.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=1500, best_for=['listwise ranking', 'multi-document'], model_path='Soyoung97/RankT5-base'), 'listt5-base': ModelMetadata(name='ListT5 Base', method='listt5', description='List-aware T5 reranker.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=1500, best_for=['list ranking', 'document sets'], model_path='Soyoung97/ListT5-base'), 'colbert-reranker': ModelMetadata(name='ColBERT Reranker', method='colbert_ranker', description='ColBERT-based reranking for fine-grained matching.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=True, memory_mb=3000, best_for=['fine-grained matching', 'high precision']), 'transformer-reranker': ModelMetadata(name='Transformer Reranker', method='transformer_ranker', description='General transformer-based cross-encoder reranker.', speed=(Speed.MEDIUM), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=1500, best_for=['general reranking', 'cross-encoder']), 'cohere-rerank': ModelMetadata(name='Cohere Reranker', method='apiranker', description="Cohere's reranking API - fast and accurate.", speed=(Speed.FAST), accuracy=(Accuracy.EXCELLENT), gpu_required=False, memory_mb=50, api_required=True, api_provider='cohere', best_for=['production', 'easy deployment', 'no gpu'], model_path='cohere'), 'jina-rerank': ModelMetadata(name='Jina Reranker', method='apiranker', description="Jina AI's reranking API.", speed=(Speed.FAST), accuracy=(Accuracy.VERY_GOOD), gpu_required=False, memory_mb=50, api_required=True, api_provider='jina', best_for=['production', 'multilingual'], model_path='jina'), 'voyage-rerank': ModelMetadata(name='Voyage Reranker', method='apiranker', description="Voyage AI's reranking API.", speed=(Speed.FAST), accuracy=(Accuracy.EXCELLENT), gpu_required=False, memory_mb=50, api_required=True, api_provider='voyage', best_for=['production', 'high quality'], model_path='voyage'), 'splade-reranker': ModelMetadata(name='SPLADE Reranker', method='splade_reranker', description='Sparse lexical and dense hybrid reranker.', speed=(Speed.FAST), accuracy=(Accuracy.VERY_GOOD), gpu_required=True, memory_mb=1200, best_for=['hybrid retrieval', 'keyword + semantic']), 'sentence-transformer-reranker': ModelMetadata(name='Sentence Transformer Reranker', method='sentence_transformer_reranker', description='Reranking with sentence transformer embeddings.', speed=(Speed.FAST), accuracy=(Accuracy.GOOD), gpu_required=True, memory_mb=1000, best_for=['semantic similarity', 'embedding-based']), 'llm2vec-reranker': ModelMetadata(name='LLM2Vec Reranker', method='llm2vec', description='LLM embeddings converted for reranking.', speed=(Speed.SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=8000, best_for=['llm-based', 'high accuracy']), 'twolar': ModelMetadata(name='TWOLAR', method='twolar', description='Two-stage list-aware reranking.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=2000, best_for=['list-aware', 'multi-stage'])}
module-attribute
RAG_METHOD_REGISTRY = {'zero-shot': ModelMetadata(name='Zero-Shot RAG', method='zero-shot', description='Direct answer generation without examples.', speed=(Speed.FAST), accuracy=(Accuracy.GOOD), gpu_required=False, memory_mb=100, best_for=['simple qa', 'fast responses']), 'basic-rag': ModelMetadata(name='Basic RAG', method='basic-rag', description='Standard RAG with context injection.', speed=(Speed.FAST), accuracy=(Accuracy.VERY_GOOD), gpu_required=False, memory_mb=100, best_for=['general qa', 'document qa']), 'chain-of-thought-rag': ModelMetadata(name='Chain-of-Thought RAG', method='chain-of-thought-rag', description='RAG with step-by-step reasoning.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=False, memory_mb=100, best_for=['complex questions', 'multi-step reasoning', 'math']), 'self-consistency-rag': ModelMetadata(name='Self-Consistency RAG', method='self-consistency-rag', description='Multiple generations with majority voting.', speed=(Speed.SLOW), accuracy=(Accuracy.STATE_OF_THE_ART), gpu_required=False, memory_mb=100, best_for=['highest accuracy', 'critical applications', 'verification']), 'react-rag': ModelMetadata(name='ReAct RAG', method='react-rag', description='Reasoning and acting interleaved.', speed=(Speed.VERY_SLOW), accuracy=(Accuracy.EXCELLENT), gpu_required=False, memory_mb=100, best_for=['multi-hop qa', 'tool use', 'complex reasoning']), 'fid-rag': ModelMetadata(name='Fusion-in-Decoder RAG', method='fid-rag', description='All contexts fused in decoder at once.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=True, memory_mb=4000, best_for=['multi-document', 'information synthesis'], model_path='google/fid-nq-base'), 'in-context-ralm': ModelMetadata(name='In-Context RALM', method='in-context-ralm', description='In-context retrieval-augmented language modeling.', speed=(Speed.MEDIUM), accuracy=(Accuracy.EXCELLENT), gpu_required=False, memory_mb=100, best_for=['few-shot learning', 'context adaptation'])}
module-attribute
__all__ = ['RankifyAgent', 'AgentResponse', 'RankifyRecommender', 'RecommendationResult', 'PipelineConfig', 'recommend', 'ModelMetadata', 'TaskType', 'Speed', 'Accuracy', 'RETRIEVER_REGISTRY', 'RERANKER_REGISTRY', 'RAG_METHOD_REGISTRY', 'get_all_retrievers', 'get_all_rerankers', 'get_all_rag_methods', 'get_model', 'filter_models']
module-attribute
ModelMetadata
dataclass
Metadata for a single model.
Source code in rankify/agent/model_registry.py
matches_constraints(constraints)
Check if model matches user constraints.
Source code in rankify/agent/model_registry.py
score_for_task(task)
Score model suitability for a task (0-1).
Source code in rankify/agent/model_registry.py
TaskType
Speed
Bases: Enum
Model speed categories.
Source code in rankify/agent/model_registry.py
Accuracy
RankifyRecommender
Intelligent model recommender for Rankify.
Recommends optimal retrievers, rerankers, and RAG methods based on user constraints and task requirements.
Source code in rankify/agent/recommender.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
recommend(task='qa', constraints=None, include_reranker=True, include_rag=False, top_k=3)
Get recommended models for a given task and constraints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str
|
Task type - "qa", "search", "summarization", "conversational", "domain_specific" |
'qa'
|
constraints
|
Optional[Dict[str, Any]]
|
Optional constraints dict with keys like: - gpu: bool - Whether GPU is available - max_memory_mb: int - Maximum memory budget - max_latency_ms: int - Maximum latency budget - api_only: bool - Only recommend API-based models - no_api: bool - Only recommend local models - language: str - Required language support |
None
|
include_reranker
|
bool
|
Whether to recommend a reranker |
True
|
include_rag
|
bool
|
Whether to recommend a RAG method |
False
|
top_k
|
int
|
Number of alternatives to include |
3
|
Returns:
| Type | Description |
|---|---|
RecommendationResult
|
RecommendationResult with recommended models and alternatives |
Source code in rankify/agent/recommender.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
recommend_for_latency(max_latency_ms, task='qa', include_reranker=True)
Recommend models optimized for latency budget.
Source code in rankify/agent/recommender.py
recommend_for_accuracy(task='qa', gpu_available=True)
Recommend highest accuracy models regardless of speed.
Source code in rankify/agent/recommender.py
recommend_for_production(gpu_available=False, api_allowed=True)
Recommend production-ready models (fast, reliable).
Source code in rankify/agent/recommender.py
RecommendationResult
dataclass
Result of a model recommendation.
Source code in rankify/agent/recommender.py
build_pipeline()
PipelineConfig
dataclass
Configuration for a complete RAG pipeline.
Source code in rankify/agent/recommender.py
to_dict()
Convert to dictionary.
Source code in rankify/agent/recommender.py
RankifyAgent
Conversational AI agent for Rankify model selection.
Supports multiple LLM backends: - Azure OpenAI - OpenAI - LiteLLM (100+ providers) - Local LLMs via transformers
Example
Source code in rankify/agent/agent.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
__init__(backend='azure', model_name=None, api_key=None, **kwargs)
Initialize RankifyAgent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
str
|
LLM backend - "azure", "openai", "litellm", "local" |
'azure'
|
model_name
|
Optional[str]
|
Model name (optional, uses defaults per backend) |
None
|
api_key
|
Optional[str]
|
API key (optional, uses environment variables) |
None
|
**kwargs
|
Additional backend-specific arguments |
{}
|
Source code in rankify/agent/agent.py
chat(user_message)
Have a conversation with the agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_message
|
str
|
User's message/question |
required |
Returns:
| Type | Description |
|---|---|
AgentResponse
|
AgentResponse with message, optional recommendation, and code snippet |
Source code in rankify/agent/agent.py
recommend(task='qa', gpu=True, api_allowed=True, include_rag=False)
Get a direct recommendation without conversation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str
|
Task type - "qa", "search", "summarization" |
'qa'
|
gpu
|
bool
|
Whether GPU is available |
True
|
api_allowed
|
bool
|
Whether API-based models are allowed |
True
|
include_rag
|
bool
|
Whether to include RAG method |
False
|
Returns:
| Type | Description |
|---|---|
RecommendationResult
|
RecommendationResult with recommended models |
Source code in rankify/agent/agent.py
clear_history()
get_available_models(model_type='all')
Get list of available models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type
|
str
|
"retriever", "reranker", "rag", or "all" |
'all'
|
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dict of model names by type |
Source code in rankify/agent/agent.py
AgentResponse
dataclass
get_all_retrievers()
get_all_rerankers()
get_all_rag_methods()
get_model(model_type, name)
Get a specific model by type and name.
Source code in rankify/agent/model_registry.py
filter_models(model_type, constraints, task=None)
Filter models by constraints and optionally score for task.
Source code in rankify/agent/model_registry.py
recommend(task='qa', gpu=True, api_allowed=True, include_rag=False)
Quick recommendation function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str
|
"qa", "search", "summarization", "conversational" |
'qa'
|
gpu
|
bool
|
Whether GPU is available |
True
|
api_allowed
|
bool
|
Whether API-based models are allowed |
True
|
include_rag
|
bool
|
Whether to include RAG method in recommendation |
False
|
Returns:
| Type | Description |
|---|---|
RecommendationResult
|
RecommendationResult with best models for the use case |