Skip to main content

Python PyPI version Downloads License

Evaluate your multimodal retrieval system in 3 lines of code.

🌟 Key Features

  • ✅ Load datasets and models with one line of code.
  • ✅ Built in support for Sentence Transformers, TIMM, BM25, and Transformers models.
  • ✅ Run benchmarks and get retrieval metrics like MRR, NormalizedDCG, Precision, Recall, HitRate, and MAP.
  • ✅ Visualize retrieval results to understand how your model is performing.
  • ✅ Combine retrieval results from multiple models using Reciprocal Rank Fusion (RRF).

🚀 Quickstart

Open In Colab Open In Kaggle

import xretrieval

metrics, results_df = xretrieval.run_benchmark(
    dataset="coco-val-2017",
    model_id="transformers/Salesforce/blip2-itm-vit-g",
    mode="text-to-text",
)
 Retrieval Metrics @ k=10 
┏━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Metric        ┃ Score  ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━┩
│ MRR           │ 0.2358 │
│ NormalizedDCG │ 0.2854 │
│ Precision     │ 0.1660 │
│ Recall        │ 0.4248 │
│ HitRate       │ 0.4248 │
│ MAP           │ 0.2095 │
└───────────────┴────────┘

📦 Installation

From PyPI:

pip install xretrieval

From source:

pip install git+https://github.com/dnth/x.retrieval

🛠️ Usage

List datasets:

xretrieval.list_datasets()
                                     Available Datasets                                      
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Dataset Name                 ┃ Description                                                ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ coco-val-2017                │ The COCO Validation Set with 5k images.                    │
│ coco-val-2017-blip2-captions │ The COCO Validation Set with 5k images and BLIP2 captions. │
│ coco-val-2017-vlrm-captions  │ The COCO Validation Set with 5k images and VLRM captions.  │
└──────────────────────────────┴────────────────────────────────────────────────────────────┘

List models:

xretrieval.list_models()
                         Available Models                         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
┃ Model ID                                         ┃ Model Input ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
│ transformers/Salesforce/blip2-itm-vit-g          │ text-image  │
│ transformers/Salesforce/blip2-itm-vit-g-text     │ text        │
│ transformers/Salesforce/blip2-itm-vit-g-image    │ image       │
│ xhluca/bm25s                                     │ text        │
│ sentence-transformers/paraphrase-MiniLM-L3-v2    │ text        │
│ sentence-transformers/paraphrase-albert-small-v2 │ text        │
│ sentence-transformers/multi-qa-distilbert-cos-v1 │ text        │
│ sentence-transformers/all-MiniLM-L12-v2          │ text        │
│ sentence-transformers/all-distilroberta-v1       │ text        │
│ sentence-transformers/multi-qa-mpnet-base-dot-v1 │ text        │
│ sentence-transformers/all-mpnet-base-v2          │ text        │
│ sentence-transformers/multi-qa-MiniLM-L6-cos-v1  │ text        │
│ sentence-transformers/all-MiniLM-L6-v2           │ text        │
│ timm/resnet18.a1_in1k                            │ image       │
└──────────────────────────────────────────────────┴─────────────┘

Run benchmarks:

results, results_df = xretrieval.run_benchmark_bm25("coco-val-2017-blip2-captions")

Visualize retrieval results:

xretrieval.visualize_retrieval(results_df)

alt text alt text

Run hybrid search with Reciprocal Rank Fusion (RRF):

results_df = xretrieval.run_rrf([results_df, results_df], "coco-val-2017")

See RRF notebook for more details.

Metadata

Release files for xretrieval 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xretrieval 0.2.0
File Size Uploaded Provenance Actions
xretrieval-0.2.0.tar.gz 14.2 kB Without provenance Details for xretrieval-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xretrieval 0.2.0
File Interpreter ABI Platform Actions
xretrieval-0.2.0-py3-none-any.whl Python 3 none any Details for xretrieval-0.2.0-py3-none-any.whl

Total release size: 31.8 kB

Release files / xretrieval-0.2.0.tar.gz

Download URL xretrieval-0.2.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
459fcb26e01791482acbe65e94d2d7a40970d52a016e2cfb1eaaeb00e1481771
BLAKE2b-256 checksum
How to use checksums
e1f26dc93eb8dc91c810044381a690cd0a9e1ef537117398961fc075ef3d1d22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / xretrieval-0.2.0-py3-none-any.whl

Download URL xretrieval-0.2.0-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1811b0ba9cae943c7c7f3df55a080dad2d63c787769c51dc8f1a75451643acd6
BLAKE2b-256 checksum
How to use checksums
dc2d03fa308d979e8ed5739bf64211dda381c4fef0c1271e29831f1971a39e15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Security for xretrieval 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page