Faithful, vector-only similarity & ranking attribution — the 'why' vector search never returns.
Project description
SimLens
See why your vectors match.
Faithful, vector-only similarity & ranking attribution — for any embedder, any vector store.
Vector search powers your RAG pipeline, your recommendations, your semantic search, your
anomaly detection. And every one of them answers a question with a black box: this
matches — score 0.83. Which concepts drove the match? Why did the wrong result rank
first? Why was the right one buried at #7? The score won't say.
SimLens turns that score into an answer — the specific, named concepts that produced it, in plain language, and it proves the breakdown adds up. It reads only the vectors, so it drops into any stack without touching your model or your database.
Think of it as SHAP for vector search: the missing explanation layer for similarity and ranking.
import simlens
# Zero setup — an exact explanation on the very first call, no training required.
ex = simlens.Explainer(metric="cosine")
attr = ex.explain(query_vec, candidate_vec)
print(attr.as_sentence())
# → "Matched mainly on 'financial-regulation' (61%), '2024-filings' (22%)."
…or skip the manual setup entirely — point autofit at your vector store and it samples
vectors, trains the dictionary, and names features from your payload fields + an
optional LLM, all in one line:
bundle = simlens.autofit(store) # zero manual labeling
# or: simlens.autofit(store, namer=simlens.naming.from_provider("openai"))
New here? docs/how-simlens-works.md is a friendly, plain-language tour of everything below.
Why teams reach for SimLens
- Answers the real questions. Not just why does A match? but why did A outrank B? — the margin, decomposed. The question search and recsys teams actually debug.
- Faithful by construction. For dot & cosine, the explanation is the arithmetic: contributions provably sum to the score. Every result ships a completeness residual so you can see exactly how exact it is — no hand-wavy storytelling.
- Three levels of zoom. Raw dimensions (exact) → learned monosemantic features → your own named concepts — one consistent, additive contract across all three.
- Steerable. "More like this, but less of that" — edit a query in concept space and search again.
- Drop-in & fast. Embedder-agnostic, database-agnostic, and backed by a compact Rust core for the per-query hot path.
- Auditable. Every explanation is stamped with a content hash of the artifacts that produced it — reproducible rationale for decisions that have to hold up.
What you can do
| Capability | Call |
|---|---|
| Explain a match (dims / features / concepts / aspects) | ex.explain(q, c, level=...) |
| Explain a ranking — why A beat B | ex.explain_margin(q, better, worse) |
| Centered "why" — discriminative, past the anisotropy baseline | ex.explain(q, c, center=True) |
| Any learned metric (cross-encoder, reranker) via Integrated Gradients | simlens.LearnedMetricExplainer(scorer).explain(q, c) |
| Why they're not more similar | ex.explain_dissimilarity(q, c) |
| Minimal reason — what breaks the match | ex.ablate(q, c, threshold=...) |
| Steer a query in concept space | ex.steer(q, {"topic": -1.0}) |
| Contrast against a background set | ex.explain_vs_corpus(q, c, foil) |
| Certify a bundle's faithfulness (signed scorecard) | bundle.certify(vectors) |
| Summarize a whole result page | ex.summarize(q, hits) |
| Late-interaction (multi-vector) attribution | simlens.MultiVectorExplainer().explain(Q, C) |
| Auto-build a bundle from your store (no manual labeling) | simlens.autofit(store) |
| Train & package a concept bundle manually | simlens.train.build_bundle(...) |
| Calibrate / audit naming confidence | simlens.eval.reliability(bundle, X, labelers) |
| Fetch candidates from your store | simlens.adapters.Qdrant / Pgvector / Faiss / Weaviate |
| Inspect, verify, evaluate from the shell | simlens info | verify | eval | serve |
| Serve over HTTP | python -m simlens.serve --bundle b.simlens |
System extensions
Thin, customizable wrappers that adapt SimLens to a system type — you bring the vectors, they bring the explanation. Business-logic-agnostic and configurable.
from simlens.integrations.rag import RagExplainer # why retrieved / why ranked
from simlens.integrations.recsys import RecsysExplainer # "because you liked …", steer
from simlens.integrations.kg import KnowledgeGraphExplainer # explain / propose / type edges
from simlens.integrations.audit import AuditLog # signed, hashed decision records
Optional extras (same package): pip install "simlens[qdrant,openai,train]" — stores
(qdrant, pgvector, faiss, weaviate), LLM naming providers (openai, gemini),
research-scale GPU training + safetensors import (train), and sublinear kNN edge
proposal (kg).
Install / build from source
python -m venv .venv && . .venv/bin/activate
pip install maturin numpy pytest
maturin develop --release # builds the Rust core into your environment
cargo test -p simlens-core # Rust unit tests
pytest -q # Python tests
python examples/quickstart.py # full end-to-end demo
Project layout
| Path | What |
|---|---|
crates/simlens-core |
Rust attribution kernels — the math and the hot path |
crates/simlens-py |
PyO3 bindings → simlens._native |
python/simlens |
Python API: Explainer, Bundle, train, eval, adapters, viz, serve |
examples/ |
Runnable, self-contained demo |
docs/ |
How SimLens works |
Status
v0.2 — trustworthy defaults, measured not asserted. Everything in v0.1 plus:
- Real SAE trainers — TopK (default), BatchTopK, JumpReLU with AuxK dead-feature revival,
a zero-dep numpy backend and an optional
torch/GPU backend; the training-time sparsity gate is reproduced at inference (train == inference), and safetensors/SAELens dictionaries drop in viaimport_safetensors_sae. - Detection-scored naming — names carry a measured balanced-accuracy (name-as-classifier), and low-scoring names are dropped instead of shown as confident nonsense.
- Centered "why" — anisotropy correction (mean / ABTT / whitening) surfaces discriminative concepts past the global-mean baseline; the default for the integrations.
- Integrated Gradients — explain any learned/non-linear scorer with a completeness axiom.
- Faithfulness certification — a signed quality scorecard (FVU, L0, dead %, deletion/ insertion AUC, detection accuracies) baked into the bundle and covered by its content hash.
- Zero-copy numpy FFI, criterion + Python benchmarks (docs/benchmarks.md), CI + abi3 wheels + PyPI/crates.io publishing, property-based & adversarial tests, and per-extension real-system validation.
Frontier (post-v0.2): a native Rust simlens-serve, cross-modal and hierarchical concepts.
Documentation
- How SimLens works — the concepts, end to end.
- Benchmarks · Real-system validation.
- LICENSE — Apache-2.0.
License
SimLens is released under the Apache License 2.0.
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 Distributions
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 simlens-0.2.0.tar.gz.
File metadata
- Download URL: simlens-0.2.0.tar.gz
- Upload date:
- Size: 75.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82d84656a0f900ee01ac0178c7f750a6e7adf3245ab7aaa629b9e566339840f9
|
|
| MD5 |
8b0add4d08842c93e589baf444300db6
|
|
| BLAKE2b-256 |
4bf087bd36b05ef9fcc3fbd51e7a2c96f361788324e5f1a1fed4a32d12f19716
|
Provenance
The following attestation bundles were made for simlens-0.2.0.tar.gz:
Publisher:
release.yml on ghassenov/simlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simlens-0.2.0.tar.gz -
Subject digest:
82d84656a0f900ee01ac0178c7f750a6e7adf3245ab7aaa629b9e566339840f9 - Sigstore transparency entry: 2084933091
- Sigstore integration time:
-
Permalink:
ghassenov/simlens@c499f463f3131302fdfb2b1860099f1a6636e8b7 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ghassenov
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c499f463f3131302fdfb2b1860099f1a6636e8b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file simlens-0.2.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: simlens-0.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 280.5 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8de6035f625893f5ba60c6ce507249b7551cd2e88e105820d3b87f69d7f3c6ea
|
|
| MD5 |
8aec50b6cbca325efde6124b9c0f2bd7
|
|
| BLAKE2b-256 |
60e98916547128a9c90985a76bf707f5e6010c24cfab4cf7c028487fed42eebd
|
Provenance
The following attestation bundles were made for simlens-0.2.0-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on ghassenov/simlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simlens-0.2.0-cp38-abi3-win_amd64.whl -
Subject digest:
8de6035f625893f5ba60c6ce507249b7551cd2e88e105820d3b87f69d7f3c6ea - Sigstore transparency entry: 2084871221
- Sigstore integration time:
-
Permalink:
ghassenov/simlens@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ghassenov
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Trigger Event:
push
-
Statement type:
File details
Details for the file simlens-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: simlens-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 392.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2efee4f177e9468fdee0f6871dfe0bfc8735cfdd44b7940476ca7d94ed39a19
|
|
| MD5 |
812731bd208254e83017c8223184ea27
|
|
| BLAKE2b-256 |
e78f6c2e867003cf172e54e4c8cf5ded1a7c57c9b740d9e0c20e84765d82616f
|
Provenance
The following attestation bundles were made for simlens-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ghassenov/simlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simlens-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
d2efee4f177e9468fdee0f6871dfe0bfc8735cfdd44b7940476ca7d94ed39a19 - Sigstore transparency entry: 2084870980
- Sigstore integration time:
-
Permalink:
ghassenov/simlens@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ghassenov
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Trigger Event:
push
-
Statement type:
File details
Details for the file simlens-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: simlens-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 385.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dcc957e2c79b11f3fe7721e05825ed78ffa3025f2e3a4f876e830b461f4dc5d
|
|
| MD5 |
864ff346bdd8f7cd1d6498945edba4f5
|
|
| BLAKE2b-256 |
6c80e184bc76930ded6f430f04b1e031fe38088d7b02f8963b3b789ae0809a5f
|
Provenance
The following attestation bundles were made for simlens-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on ghassenov/simlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simlens-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
7dcc957e2c79b11f3fe7721e05825ed78ffa3025f2e3a4f876e830b461f4dc5d - Sigstore transparency entry: 2084871121
- Sigstore integration time:
-
Permalink:
ghassenov/simlens@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ghassenov
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Trigger Event:
push
-
Statement type:
File details
Details for the file simlens-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: simlens-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 662.8 kB
- Tags: CPython 3.8+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61d70e971ba87119f01ced1fd9a9b1c4342c81a0fbfb5b13e0c3116ae406f7f7
|
|
| MD5 |
284f396896f345bb07e8a33801f07c03
|
|
| BLAKE2b-256 |
b9627ba6b1644b46a8a99aa86d55aa00aa2686381946e505e91d353a82110554
|
Provenance
The following attestation bundles were made for simlens-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on ghassenov/simlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simlens-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
61d70e971ba87119f01ced1fd9a9b1c4342c81a0fbfb5b13e0c3116ae406f7f7 - Sigstore transparency entry: 2084870883
- Sigstore integration time:
-
Permalink:
ghassenov/simlens@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ghassenov
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b94efcc27c8ec2f0417bafbc19cecbac65552015 -
Trigger Event:
push
-
Statement type: