ONNX Model Zoo

textualization/all-distilroberta-v1

By textualization · ↓ 1 · ♥ 0 · Updated 2024-02-06

What's in this repo

This page lists the files in textualization/all-distilroberta-v1, including model.onnx.

  • 1 ONNX models (.onnx files)
  • 10 files, including 6 .json, 1 .md, 1 .txt, 1 .onnx
  • Last updated 2024-02-06

ONNX files

File Size Download
model.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

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.

Model info

sentence-similarity sentence-transformers
sentence-transformers onnx roberta feature-extraction sentence-similarity en dataset:s2orc dataset:flax-sentence-embeddings/stackexchange_xml dataset:MS_Marco dataset:gooaq dataset:yahoo_answers_topics dataset:code_search_net
↓ 1 ♥ 0

Created: 2024-02-06

Updated: 2024-02-06

View on Hugging Face

Files (10)

.gitattributes
README.md
config.json
merges.txt
model.onnx ONNX
ort_config.json
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.json

Related models