Skip to main content

Ultralight and Fast wrapper for the independent implementation of SPLADE++ models for your search & retrieval pipelines. Models and Library created by Prithivi Da, For PRs and Collaboration to checkout the readme.

Project description

SPLADERunner

Title is dedicated to the Original Blade Runners - Harrison Ford and the Author Philip K. Dick of "Do Androids Dream of Electric Sheep?"

Thanks to Nils Reimers for

  • All the MS-MARCO hard negatives.
  • All his work in IR space, Pushing BEIR and MTEB benchmarks.
  • The trolls :-) and
  • For all the timely inputs especially around evaluation.

Thanks to Naver folks, the original authors of the paper for such a robust research.

What is it?

A Ultra-lite & Super-fast Python wrapper for the independent implementation of SPLADEPlusPlus models for your search & retrieval pipelines. Based on the papers "From Distillation to Hard Negative Sampling: Making Sparse Neural IR Models More Effective":https://arxiv.org/pdf/2205.04733.pdf and "SPLADEv2": https://arxiv.org/abs/2109.10086 with some minor tweaks.

  1. Ultra-lite & Superfast:

    • No Torch or Transformers needed. Runs on CPU.
    • Retrieval Efficient: Token budget concious models, hence low latency retrievals. Anserini numbers.
    • Inference / Serving Efficient: Optimised for best inference performance.
  2. Note on Retrieval Efficieny and Industry suitability. Goal was not to be the SoTA model, but to be competitive yet efficient. Show the Token budget difference. FLOPS

🚀 Installation:

pip install spladerunner

Usage:

#One-time init
from spladerunner import Expander
expander = Expander() # Default is do expander model.

#Sample Document expansion
sparse_rep = expander.expand("The Manhattan Project and its atomic bomb helped bring an end to World War II. Its legacy of peaceful uses of atomic energy continues to have an impact on history and science.")

Why Sparse Representations?

(Feel free to skip to 3 If you are expert in sparse and dense representations)

  • Lexical search with BOW based sparse vectors are strong baselines, but they famously suffer from vocabulary mismatch problem, as they can only do exact term matching.

Pros

✅ Efficient and Cheap.
✅ No need to fine-tune models.
✅️ Interpretable.
✅️ Exact Term Matches.

Cons

❌ Vocabulary mismatch (Need to remember exact terms)

  • Semantic Search Learned Neural / Dense retrievers with approximate nearest neighbors search has shown impressive results but they can

Pros

✅ Search how humans innately think.
✅ When finetuned beats sparse by long way.
✅ Easily works with Multiple modals.

Cons

❌ Suffers token amnesia (misses term matching), 
❌ Resource intensive (both index & retreival), 
❌ Famously hard to interpret.
❌ Needs fine-tuning for OOD data.

  • Getting pros of both searches made sense and that gave rise to interest in learning sparse representations for queries and documents with some interpretability. The sparse representations also double as implicit or explicit (latent, contextualized) expansion mechanisms for both query and documents. If you are new to query expansion learn more here from Daniel Tunkelang.

2b. What the Models learn?

  • The model learns to project it's learned dense representations over a MLM head to give a vocabulary distribution.

3. 💸 Why SPLADERunner?:

- **$ Concious:** Serverless deployments like Lambda are charged by memory & time per invocation*
- **Smaller package size** = shorter cold start times, quicker re-deployments for Serverless.
- **Permissive License**. (You can use it commercially with Source attribution).

4. 🎯 Models:

- Below are the list of models supported as of now.
    * [DOST/SPLADEplusplus_EN](https://huggingface.co/DOST/SPLADEplusplus_EN) (default model)
  1. 💸 Where and How can you use?
  • [TBD]
  1. How (and what) to contribute?
  • [TBD]
  1. Criticisms and Competitions to SPLADE and Learned Sparse representations:

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

SPLADERunner-0.0.5.tar.gz (5.9 kB view hashes)

Uploaded Source

Built Distribution

SPLADERunner-0.0.5-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

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