Skip to main content

Retrieve and Evaluate with X(any) models

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xretrieval-0.2.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xretrieval-0.2.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file xretrieval-0.2.0.tar.gz.

File metadata

  • Download URL: xretrieval-0.2.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for xretrieval-0.2.0.tar.gz
Algorithm Hash digest
SHA256 459fcb26e01791482acbe65e94d2d7a40970d52a016e2cfb1eaaeb00e1481771
MD5 04e279423c0e7ab60d3dd631595916c9
BLAKE2b-256 e1f26dc93eb8dc91c810044381a690cd0a9e1ef537117398961fc075ef3d1d22

See more details on using hashes here.

File details

Details for the file xretrieval-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: xretrieval-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for xretrieval-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1811b0ba9cae943c7c7f3df55a080dad2d63c787769c51dc8f1a75451643acd6
MD5 7647a084edc6010d7f06ec3f63a77aa4
BLAKE2b-256 dc2d03fa308d979e8ed5739bf64211dda381c4fef0c1271e29831f1971a39e15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page