ONNX 模型库
返回模型

说明文档

distiluse-base-multilingual-cased-v2 的 ONNX 转换版本

sentence-transformers/distiluse-base-multilingual-cased-v2 的转换

这是一个 sentence-transformers 的 ONNX 模型:它将句子和段落映射到一个 512 维的稠密向量空间,可用于聚类或语义搜索等任务。此自定义模型输出 last_hidden_state,与原始 sentence-transformer 实现类似。

使用方法(HuggingFace Optimum)

安装 optimum 后,使用此模型变得非常简单:

python -m pip install optimum

您可能还需要安装以下依赖:

python -m pip install onnxruntime
python -m pip install onnx

然后您可以像这样使用该模型:

from optimum.onnxruntime.modeling_ort import ORTModelForCustomTasks

model = ORTModelForCustomTasks.from_pretrained("lorenpe2/distiluse-base-multilingual-cased-v2")
tokenizer = AutoTokenizer.from_pretrained("lorenpe2/distiluse-base-multilingual-cased-v2")
inputs = tokenizer("I love burritos!", return_tensors="pt")
pred = model(**inputs)

您还可以利用 transformers 中的 pipeline API:

from transformers import pipeline

onnx_extractor = pipeline("feature-extraction", model=model, tokenizer=tokenizer)
text = "I love burritos!"
pred = onnx_extractor(text)

评估结果

有关此模型的自动评估,请参阅 Sentence Embeddings Benchmarkhttps://seb.sbert.net

完整模型架构

SentenceTransformer(
  (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: DistilBertModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
  (2): Dense({'in_features': 768, 'out_features': 512, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'})
)

引用与作者

此模型由 sentence-transformers 训练。

如果您发现此模型有帮助,欢迎引用我们的论文 Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks

@inproceedings{reimers-2019-sentence-bert,
    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2019",
    publisher = "Association for Computational Linguistics",
    url = "http://arxiv.org/abs/1908.10084",
}

lorenpe2/distiluse-base-multilingual-cased-v2

作者 lorenpe2

sentence-similarity sentence-transformers
↓ 1 ♥ 0

创建时间: 2023-07-27 08:56:23+00:00

更新时间: 2023-07-27 09:13:27+00:00

在 Hugging Face 上查看

文件 (8)

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