Retrieval Models Explainability Toolkit. Explain embedding similarity prediction.
Project description
Retrivex
Retrivex is retrieval models explainability toolkit.
Explainability for embedding similarity models (siamese encoders, bi-encoders, dense retrieval models, embedding models, etc.). Debug your vector search models. Explain output of retrieval component of your RAG or agentic AI system. Detect errors, biases or unintended behavior in your information retrieval system.
Explain similarity score in a couple lines of code:
# ...
results = explainer.explain(
"Carbs are broken down into sugar in your body",
"Carbohydrates are metabolized into glucose")
visualization.plot_connections(*results)
Goal
The goal of the project is to collect and implement specialized methods of retrieval models explainability proposed in academic research into a reliable and generalized toolkit. This toolkit will consolidate state-of-the-art approaches into a practical, standardized framework enabling robustness, reproduciblility and usability for real-world applications.
Why Specialized Methods for Retrieval Explainability?
Explainability of retrieval models like dense encoders requires specialized methods because their outputs differ fundamentally from classification or regression models. Instead of predicting a class they compute a continuous similarity score between pairs of inputs making classical perturbation-based explainability tools like LIME less applicable. Explanations must capture the interaction between two items (query and candidate), not just features of a single input. Since these models rely on high-dimensional embeddings feature attributions at the raw input level often miss how latent dimensions drive similarity. Therefore, tailored approaches such as gradient-based attribution in embedding space or concept-level alignment are essential for meaningful explanations.
Why Explainability of Retrieval Models?
Explainability in information retrieval (IR) models is crucial because it helps to understand why certain documents or items are retrieved and ranked higher than others. Transparent explanations improve trust and adoption, especially in high-stakes domains like healthcare, law, or finance, where decisions based on retrieved information can have significant consequences. It also enables debugging and model improvement allowing researchers and engineers to detect biases, errors or unintended behavior in retrieval systems.
Features of the Project
- Explanation in a couple lines of code
- Seamless integration with SentenceTransformers
- Explainability for your custom fine-tuned SentenceTransformers model
- Visualization tools
- Integrated Jacobians explanability method in accordance to Moeller et al., EACL 2024.
- To Be Added Next: BiLRP explanability method in accordance to Vasileiou & Eberle, NAACL 2024
Installation
From sources
You need Python 3.9+ to run code in this tutorial. To install retrivex toolkit from sources run the following command:
pip install git+https://github.com/aikho/retrivex.git
Example
from retrivex.stransformers import IntJacobianExplainableTransformer
from retrivex.visualization import plot_connections
explainer = IntJacobianExplainableTransformer("all-MiniLM-L6-v2")
results = explainer.explain(
"Carbs are broken down into sugar in your body",
"Carbohydrates are metabolized into glucose")
plot_connections(*results)
See more examples in the Tutorial.
Documentation
See toolkit API documentation
Tested Models
Integrated Jacobians explainer was tested on the following SentenceTransformers models:
- Original SenetenceTransformers models:
all-MiniLM-L6-v2all-MiniLM-L12-v2all-roberta-large-v1all-distilroberta-v1paraphrase-multilingual-MiniLM-L12-v2paraphrase-MiniLM-L3-v2multi-qa-MiniLM-L6-cos-v1multi-qa-MiniLM-L6-dot-v1
- T5-based models:
gtr-t5-base
- Gemma Models:
embeddinggemma-300m-medical
- JinaAI models:
jinaai/jina-embeddings-v2-base-enjinaai/jina-embeddings-v2-base-code
- BAAI models:
BAAI/bge-base-en-v1.5BAAI/bge-code-v1BAAI/bge-small-en-v1.5BAAI/bge-m3
- E5-based models:
intfloat/e5-base-v2intfloat/multilingual-e5-largeintfloat/multilingual-e5-small
Future Work
- Add BiLRP explanability method
- Support of more models for Integrated Jacobians method
- Add implement of other explanability methods
- Add explanability methods for RecSys models
- Add more tools for visualization
License
See LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file retrivex-0.1.0.tar.gz.
File metadata
- Download URL: retrivex-0.1.0.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f52ec2ad8933bd4af15e0db24243f0319ecfe8e5e1e830eedb2f66d5567cb39a
|
|
| MD5 |
4d0556cef53175b9b13f26312a77e728
|
|
| BLAKE2b-256 |
64dc841d0bb95aa170e982dfe08b4ae0842f721612c0052960b37b1e20478d46
|
File details
Details for the file retrivex-0.1.0-py3-none-any.whl.
File metadata
- Download URL: retrivex-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3edd81d420bf06eb4e6cab45783f76bb4c6b78ce5e4564f48e78f7af1b7cea2
|
|
| MD5 |
f02790580c7885026e9b59aac49adf03
|
|
| BLAKE2b-256 |
a84e41907adcace6181440bdd7366deac45a36be89f77915230e151c64719eb5
|