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.
Metadata
Release files for retrivex 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| retrivex-0.1.0.tar.gz | 25.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| retrivex-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.5 kB
Release files / retrivex-0.1.0.tar.gz
| Download URL | retrivex-0.1.0.tar.gz |
|---|---|
| Size | 25.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f52ec2ad8933bd4af15e0db24243f0319ecfe8e5e1e830eedb2f66d5567cb39a
|
|
BLAKE2b-256 checksum How to use checksums |
64dc841d0bb95aa170e982dfe08b4ae0842f721612c0052960b37b1e20478d46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / retrivex-0.1.0-py3-none-any.whl
| Download URL | retrivex-0.1.0-py3-none-any.whl |
|---|---|
| Size | 25.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3edd81d420bf06eb4e6cab45783f76bb4c6b78ce5e4564f48e78f7af1b7cea2
|
|
BLAKE2b-256 checksum How to use checksums |
a84e41907adcace6181440bdd7366deac45a36be89f77915230e151c64719eb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for retrivex 0.1.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.