Sentence Similarity
sentence-transformers
ONNX
English
roberta
feature-extraction
Inference Endpoints
Edit model card

This is a ONNX export of sentence-transformers/all-distilroberta-v1.

The export was done using HF Optimum:

from optimum.exporters.onnx import main_export

main_export('sentence-transformers/all-distilroberta-v1', "./output", cache_dir='./cache', optimize='O1') 

Please note, this ONNX model does not contain the mean pooling layer, it needs to be done in code afterwards or the embeddings won't work.

Code like this:

#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
    token_embeddings = model_output[0] #First element of model_output contains all token embeddings
    input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
    return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)

See the example code from the original model in the "Usage (HuggingFace Transformers)" section.

Downloads last month
0

Datasets used to train textualization/all-distilroberta-v1