Instructions to use opensearch-project/opensearch-neural-sparse-encoding-v2-distill with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use opensearch-project/opensearch-neural-sparse-encoding-v2-distill with sentence-transformers:
from sentence_transformers import SparseEncoder model = SparseEncoder("opensearch-project/opensearch-neural-sparse-encoding-v2-distill") queries = ["Which planet is known as the Red Planet?"] documents = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", ] query_embeddings = model.encode_query(queries) document_embeddings = model.encode_document(documents) similarities = model.similarity(query_embeddings, document_embeddings) print(similarities) - Transformers
How to use opensearch-project/opensearch-neural-sparse-encoding-v2-distill with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="opensearch-project/opensearch-neural-sparse-encoding-v2-distill")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("opensearch-project/opensearch-neural-sparse-encoding-v2-distill") model = AutoModelForMaskedLM.from_pretrained("opensearch-project/opensearch-neural-sparse-encoding-v2-distill", device_map="auto") - Notebooks
- Google Colab
- Kaggle
How did you evaluate BEIR?
I am trying to reproduce your BEIR results. Some results match exactly but others are lower than the numbers in your model card. What tool did you use to evaluate BEIR? I am currently using pyserini & the beir package.
Hi @freethenation , we are using OpenSearch as the evaluate engine. The max input length is 512 tokens. Please note that for some BEIR dataset, we need to filter out the query id from the search results, because for these datasets queries and documents are from the same space.
Evaluation code is available here: https://github.com/zhichao-aws/opensearch-sparse-model-tuning-sample/tree/main