Transformer-based ranking models, such as MonoBERT, are central to Information Retrieval; yet their inner workings remain largely opaque. This hinders not only our understanding of the systems implementing them, but also our ability to improve them.
IR Lens is a new interpretability tool tailored to cross-encoders, based on two key components:
With its interactive graphical interface, IR Lens enables IR practitioners to explore, analyze, and manipulate neuron-level mechanisms in cross-encoders, facilitating a deeper understanding of neural ranking models. By extending the reach of existing interpretability methods, we believe IR Lens has the potential to support the improvement of cross-encoders.
IR Lens is implemented as a web-based system combining a reactive frontend with a backend for attribution computation and model inference.
Frontend: Built using Marcelle (Françoise et al., 2021), a toolkit for building interactive machine learning interfaces based on SvelteKit (Svelte 5), styled with TailwindCSS and DaisyUI. Custom interpretability visualizations are implemented with D3.js (Bostock et al., 2011).
Backend: Built on the Marcelle server infrastructure, using FeathersJS over Socket.IO for real-time communication and MongoDB for persistence.
Python Service: A dedicated Python service, connected to the backend, performs model inference, attribution computation, and ablation-based forward passes. The service exposes endpoints returning structured outputs for IGs and NIGs computation, conditional NIGs, and forward passes with and without ablations.
Real-time Updates: Results are persisted in MongoDB and streamed back to the frontend, allowing visualizations to update in real time. Users can save snapshots of NIG values and prunes, enabling them to revisit previous analyses.
Separating computation from interaction ensures that computationally intensive operations do not compromise interface responsiveness while maintaining a tight integration between attribution results and user-driven exploration.
The primary application code lives in src/ with backend configuration in backend/. The easiest way to explore the UI is to run the development server and open the app in your browser.
npm install -g pnpm)This project uses the development branch of Marcelle. Full setup instructions can be found at https://next.marcelle.dev/guides/quickstart.html.
To build a local version of Marcelle libraries:
git clone git@github.com:marcellejs/marcelle.git
cd marcelle
git checkout develop
pnpm i
pnpm build
Ensure the marcelle folder is at the same level as this project, as dependencies are linked locally via link:../marcelle/packages/*.
pnpm install
IR Lens uses MongoDB as the data store for persistence.
Download MongoDB Community Server from https://www.mongodb.com/try/download/community
Install following the instructions for your operating system
Start MongoDB: specific to your OS
Verify MongoDB is running on the default port 27017:
mongosh
Start the backend server:
pnpm backend
The backend runs on port 3030 by default. Configuration files are in backend/config/.
Environment variables should be placed in .env files in the appropriate directories:
.env: For frontend and backend servicesModel/.env: For the Python service.env)| Variable | Description | Default |
|---|---|---|
HOSTNAME | Backend host | localhost |
PORT | Backend port | 3030 |
MONGODB_URL | MongoDB connection string | mongodb://localhost:27017/my_app |
FEATHERS_SECRET | JWT secret for authentication | (set in config) |
MARCELLE_LOGIN | Admin user email for first user | |
MARCELLE_PWD | Admin user password |
Model/.env)| Variable | Description | Default |
|---|---|---|
MARCELLE_BACKEND_SERVER | Backend server address | localhost |
MARCELLE_BACKEND_PORT | Backend port | 3030 |
MARCELLE_LOGIN | User email for authentication | |
MARCELLE_PWD | User password for authentication |
Changing environment variables requires restarting the respective services.
The Python model code needs to access all saved data in MongoDB. To enable this:
admin or superadmin roleMARCELLE_LOGIN and MARCELLE_PWD environment variables to this user's credentialsPermissions are configured in backend/config/default.json. The superadmin and admin roles have manage access to all subjects.
The model and interpretability code lives in Model/.
Install Python dependencies:
cd Model
pip install -r requirements.txt
Key dependencies include:
torch==2.0.0transformers==4.24.0ir_datasets==0.5.5python-socketio[client]==5.9.0IR Lens provides direct access to TREC-DL 2019 queries and annotated passages, sorted by relevance levels. TREC-DL 2019 is based on the MS MARCO passage ranking dataset.
ir_datasets.load("msmarco-passage/trec-dl-2019/judged")The dataset is automatically downloaded by ir_datasets on first run.
In addition to the provided dataset, users can experiment with their own custom query-passage pairs directly in the interface.
To keep inference time reasonable, we limit the choice of cross-encoder to one based on the MiniLM-v2 backbone:
cross-encoder/ms-marco-MiniLM-L12-v2from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/ms-marco-MiniLM-L12-v2")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
The Python backend dynamically reads model architecture from model.config (number of layers, attention heads, intermediate size), making it adaptable to different BERT-like cross-encoders.
To use a different model or dataset, you would need to:
cd Model
python model.py
The script connects to the Marcelle backend and listens for requests from the frontend.
pnpm dev
Open http://localhost:5173 to view the app. The page reloads on edits.
pnpm build
Builds a static copy of the site to dist/.
model.py: Main model server with dataset loading and inferenceintegrated_gradients.py: Integrated Gradients implementationneuron_integrated_gradients.py: Neuron-level IGaggregation.py: NIG aggregation logicprune.py: Ablation/pruning utilitiesrequirements.txt: Python dependenciesFor containerized deployment, compose files are provided for both the frontend/backend services and the Python model service.
The backend, frontend, and MongoDB services can run in separate containers. In a production setup:
A compose.yml file is provided in the project root.
All environment variables are set in the root .env file. Changing these variables requires recreating the containers.
The Python model service has its own compose.yml in the Model/ directory.
The downloaded datasets are stored as a volume (e.g., /data/nig-viz/datasets on the host).
Environment variables are set in Model/.env. Changing these requires recreating the container.
To reset the MongoDB database, delete the volume:
docker volume rm ir-lens_db
See LICENSE.
1 commits
Svelte
63.2%
Python
24.2%
JavaScript
5.7%
TypeScript
5.6%
Transformer-based ranking models, such as MonoBERT, are central to Information Retrieval; yet their inner workings remain largely opaque. This hinders not only our understanding of the systems implementing them, but also our ability to improve them.
IR Lens is a new interpretability tool tailored to cross-encoders, based on two key components:
With its interactive graphical interface, IR Lens enables IR practitioners to explore, analyze, and manipulate neuron-level mechanisms in cross-encoders, facilitating a deeper understanding of neural ranking models. By extending the reach of existing interpretability methods, we believe IR Lens has the potential to support the improvement of cross-encoders.
IR Lens is implemented as a web-based system combining a reactive frontend with a backend for attribution computation and model inference.
Frontend: Built using Marcelle (Françoise et al., 2021), a toolkit for building interactive machine learning interfaces based on SvelteKit (Svelte 5), styled with TailwindCSS and DaisyUI. Custom interpretability visualizations are implemented with D3.js (Bostock et al., 2011).
Backend: Built on the Marcelle server infrastructure, using FeathersJS over Socket.IO for real-time communication and MongoDB for persistence.
Python Service: A dedicated Python service, connected to the backend, performs model inference, attribution computation, and ablation-based forward passes. The service exposes endpoints returning structured outputs for IGs and NIGs computation, conditional NIGs, and forward passes with and without ablations.
Real-time Updates: Results are persisted in MongoDB and streamed back to the frontend, allowing visualizations to update in real time. Users can save snapshots of NIG values and prunes, enabling them to revisit previous analyses.
Separating computation from interaction ensures that computationally intensive operations do not compromise interface responsiveness while maintaining a tight integration between attribution results and user-driven exploration.
The primary application code lives in src/ with backend configuration in backend/. The easiest way to explore the UI is to run the development server and open the app in your browser.
npm install -g pnpm)This project uses the development branch of Marcelle. Full setup instructions can be found at https://next.marcelle.dev/guides/quickstart.html.
To build a local version of Marcelle libraries:
git clone git@github.com:marcellejs/marcelle.git
cd marcelle
git checkout develop
pnpm i
pnpm build
Ensure the marcelle folder is at the same level as this project, as dependencies are linked locally via link:../marcelle/packages/*.
pnpm install
IR Lens uses MongoDB as the data store for persistence.
Download MongoDB Community Server from https://www.mongodb.com/try/download/community
Install following the instructions for your operating system
Start MongoDB: specific to your OS
Verify MongoDB is running on the default port 27017:
mongosh
Start the backend server:
pnpm backend
The backend runs on port 3030 by default. Configuration files are in backend/config/.
Environment variables should be placed in .env files in the appropriate directories:
.env: For frontend and backend servicesModel/.env: For the Python service.env)| Variable | Description | Default |
|---|---|---|
HOSTNAME | Backend host | localhost |
PORT | Backend port | 3030 |
MONGODB_URL | MongoDB connection string | mongodb://localhost:27017/my_app |
FEATHERS_SECRET | JWT secret for authentication | (set in config) |
MARCELLE_LOGIN | Admin user email for first user | |
MARCELLE_PWD | Admin user password |
Model/.env)| Variable | Description | Default |
|---|---|---|
MARCELLE_BACKEND_SERVER | Backend server address | localhost |
MARCELLE_BACKEND_PORT | Backend port | 3030 |
MARCELLE_LOGIN | User email for authentication | |
MARCELLE_PWD | User password for authentication |
Changing environment variables requires restarting the respective services.
The Python model code needs to access all saved data in MongoDB. To enable this:
admin or superadmin roleMARCELLE_LOGIN and MARCELLE_PWD environment variables to this user's credentialsPermissions are configured in backend/config/default.json. The superadmin and admin roles have manage access to all subjects.
The model and interpretability code lives in Model/.
Install Python dependencies:
cd Model
pip install -r requirements.txt
Key dependencies include:
torch==2.0.0transformers==4.24.0ir_datasets==0.5.5python-socketio[client]==5.9.0IR Lens provides direct access to TREC-DL 2019 queries and annotated passages, sorted by relevance levels. TREC-DL 2019 is based on the MS MARCO passage ranking dataset.
ir_datasets.load("msmarco-passage/trec-dl-2019/judged")The dataset is automatically downloaded by ir_datasets on first run.
In addition to the provided dataset, users can experiment with their own custom query-passage pairs directly in the interface.
To keep inference time reasonable, we limit the choice of cross-encoder to one based on the MiniLM-v2 backbone:
cross-encoder/ms-marco-MiniLM-L12-v2from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/ms-marco-MiniLM-L12-v2")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
The Python backend dynamically reads model architecture from model.config (number of layers, attention heads, intermediate size), making it adaptable to different BERT-like cross-encoders.
To use a different model or dataset, you would need to:
cd Model
python model.py
The script connects to the Marcelle backend and listens for requests from the frontend.
pnpm dev
Open http://localhost:5173 to view the app. The page reloads on edits.
pnpm build
Builds a static copy of the site to dist/.
model.py: Main model server with dataset loading and inferenceintegrated_gradients.py: Integrated Gradients implementationneuron_integrated_gradients.py: Neuron-level IGaggregation.py: NIG aggregation logicprune.py: Ablation/pruning utilitiesrequirements.txt: Python dependenciesFor containerized deployment, compose files are provided for both the frontend/backend services and the Python model service.
The backend, frontend, and MongoDB services can run in separate containers. In a production setup:
A compose.yml file is provided in the project root.
All environment variables are set in the root .env file. Changing these variables requires recreating the containers.
The Python model service has its own compose.yml in the Model/ directory.
The downloaded datasets are stored as a volume (e.g., /data/nig-viz/datasets on the host).
Environment variables are set in Model/.env. Changing these requires recreating the container.
To reset the MongoDB database, delete the volume:
docker volume rm ir-lens_db
See LICENSE.
1 commits
Svelte
63.2%
Python
24.2%
JavaScript
5.7%
TypeScript
5.6%