sentence-transformers / msmarco-distilbert-base-tas-b

huggingface.co
Total runs: 120.8K
24-hour runs: 1.7K
7-day runs: 6.2K
30-day runs: 31.5K
Model's Last Updated: November 06 2024
sentence-similarity

Introduction of msmarco-distilbert-base-tas-b

Model Details of msmarco-distilbert-base-tas-b

sentence-transformers/msmarco-distilbert-base-tas-b

This is a port of the DistilBert TAS-B Model to sentence-transformers model: It maps sentences & paragraphs to a 768 dimensional dense vector space and is optimized for the task of semantic search.

Usage (Sentence-Transformers)

Using this model becomes easy when you have sentence-transformers installed:

pip install -U sentence-transformers

Then you can use the model like this:

from sentence_transformers import SentenceTransformer, util

query = "How many people live in London?"
docs = ["Around 9 Million people live in London", "London is known for its financial district"]

#Load the model
model = SentenceTransformer('sentence-transformers/msmarco-distilbert-base-tas-b')

#Encode query and documents
query_emb = model.encode(query)
doc_emb = model.encode(docs)

#Compute dot score between query and all document embeddings
scores = util.dot_score(query_emb, doc_emb)[0].cpu().tolist()

#Combine docs & scores
doc_score_pairs = list(zip(docs, scores))

#Sort by decreasing score
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)

#Output passages & scores
for doc, score in doc_score_pairs:
    print(score, doc)
Usage (HuggingFace Transformers)

Without sentence-transformers , you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.

from transformers import AutoTokenizer, AutoModel
import torch

#CLS Pooling - Take output from first token
def cls_pooling(model_output):
    return model_output.last_hidden_state[:,0]

#Encode text
def encode(texts):
    # Tokenize sentences
    encoded_input = tokenizer(texts, padding=True, truncation=True, return_tensors='pt')

    # Compute token embeddings
    with torch.no_grad():
        model_output = model(**encoded_input, return_dict=True)

    # Perform pooling
    embeddings = cls_pooling(model_output)

    return embeddings


# Sentences we want sentence embeddings for
query = "How many people live in London?"
docs = ["Around 9 Million people live in London", "London is known for its financial district"]

# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/msmarco-distilbert-base-tas-b")
model = AutoModel.from_pretrained("sentence-transformers/msmarco-distilbert-base-tas-b")

#Encode query and docs
query_emb = encode(query)
doc_emb = encode(docs)

#Compute dot score between query and all document embeddings
scores = torch.mm(query_emb, doc_emb.transpose(0, 1))[0].cpu().tolist()

#Combine docs & scores
doc_score_pairs = list(zip(docs, scores))

#Sort by decreasing score
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)

#Output passages & scores
for doc, score in doc_score_pairs:
    print(score, doc)
Evaluation Results

For an automated evaluation of this model, see the Sentence Embeddings Benchmark : https://seb.sbert.net

Full Model Architecture
SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: DistilBertModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)
Citing & Authors

Have a look at: DistilBert TAS-B Model

Runs of sentence-transformers msmarco-distilbert-base-tas-b on huggingface.co

120.8K
Total runs
1.7K
24-hour runs
1.6K
3-day runs
6.2K
7-day runs
31.5K
30-day runs

More Information About msmarco-distilbert-base-tas-b huggingface.co Model

More msmarco-distilbert-base-tas-b license Visit here:

https://choosealicense.com/licenses/apache-2.0

msmarco-distilbert-base-tas-b huggingface.co

msmarco-distilbert-base-tas-b huggingface.co is an AI model on huggingface.co that provides msmarco-distilbert-base-tas-b's model effect (), which can be used instantly with this sentence-transformers msmarco-distilbert-base-tas-b model. huggingface.co supports a free trial of the msmarco-distilbert-base-tas-b model, and also provides paid use of the msmarco-distilbert-base-tas-b. Support call msmarco-distilbert-base-tas-b model through api, including Node.js, Python, http.

sentence-transformers msmarco-distilbert-base-tas-b online free

msmarco-distilbert-base-tas-b huggingface.co is an online trial and call api platform, which integrates msmarco-distilbert-base-tas-b's modeling effects, including api services, and provides a free online trial of msmarco-distilbert-base-tas-b, you can try msmarco-distilbert-base-tas-b online for free by clicking the link below.

sentence-transformers msmarco-distilbert-base-tas-b online free url in huggingface.co:

https://huggingface.co/sentence-transformers/msmarco-distilbert-base-tas-b

msmarco-distilbert-base-tas-b install

msmarco-distilbert-base-tas-b is an open source model from GitHub that offers a free installation service, and any user can find msmarco-distilbert-base-tas-b on GitHub to install. At the same time, huggingface.co provides the effect of msmarco-distilbert-base-tas-b install, users can directly use msmarco-distilbert-base-tas-b installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

msmarco-distilbert-base-tas-b install url in huggingface.co:

https://huggingface.co/sentence-transformers/msmarco-distilbert-base-tas-b

Url of msmarco-distilbert-base-tas-b

Provider of msmarco-distilbert-base-tas-b huggingface.co

sentence-transformers
ORGANIZATIONS

Other API from sentence-transformers