This is a SPLADE Sparse Encoder model. It maps sentences & paragraphs to a 30522-dimensional sparse vector space and can be used for semantic search and sparse retrieval.
1from sentence_transformers import SparseEncoder
23# Download from the 🤗 Hub4model = SparseEncoder("naver/splade_v2_distil")5# Run inference6queries =["what causes aging fast"]7documents =[8"UV-A light, specifically, is what mainly causes tanning, skin aging, and cataracts, UV-B causes sunburn, skin aging and skin cancer, and UV-C is the strongest, and therefore most effective at killing microorganisms. Again â\x80\x93 single words and multiple bullets.",9"Answers from Ronald Petersen, M.D. Yes, Alzheimer's disease usually worsens slowly. But its speed of progression varies, depending on a person's genetic makeup, environmental factors, age at diagnosis and other medical conditions. Still, anyone diagnosed with Alzheimer's whose symptoms seem to be progressing quickly â\x80\x94 or who experiences a sudden decline â\x80\x94 should see his or her doctor.",10"Bell's palsy and Extreme tiredness and Extreme fatigue (2 causes) Bell's palsy and Extreme tiredness and Hepatitis (2 causes) Bell's palsy and Extreme tiredness and Liver pain (2 causes) Bell's palsy and Extreme tiredness and Lymph node swelling in children (2 causes)",11]12query_embeddings = model.encode_query(queries)13document_embeddings = model.encode_document(documents)14print(query_embeddings.shape, document_embeddings.shape)15# [1, 30522] [3, 30522]1617# Get the similarity scores for the embeddings18similarities = model.similarity(query_embeddings, document_embeddings)19print(similarities)20# tensor([[15.0450, 13.3137, 5.3127]])21
Citation
If you use our checkpoint, please cite our work:
@article{formal2021splade,
title={SPLADE v2: Sparse lexical and expansion model for information retrieval},
author={Formal, Thibault and Lassance, Carlos and Piwowarski, Benjamin and Clinchant, St{\'e}phane},
journal={arXiv preprint arXiv:2109.10086},
year={2021}
}