ONNX Model Zoo

cross-encoder/monoelectra-large

By cross-encoder · ↓ 16 · ♥ 3 · Updated 2025-04-15

What's in this repo

This page lists the files in cross-encoder/monoelectra-large, including model.onnx, model_O1.onnx, model_O2.onnx and more.

  • 9 ONNX models (.onnx files)
  • 22 files, including 9 .onnx, 4 .json, 2 .bin, 2 .xml, 1 .md, 1 .safetensors
  • Last updated 2025-04-15

ONNX files

File Size Download
onnx/model.onnx — Download
onnx/model_O1.onnx — Download
onnx/model_O2.onnx — Download
onnx/model_O3.onnx — Download
onnx/model_O4.onnx — Download
onnx/model_qint8_arm64.onnx — Download
onnx/model_qint8_avx512.onnx — Download
onnx/model_qint8_avx512_vnni.onnx — Download
onnx/model_quint8_avx2.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

Cross-Encoder for Text Ranking

This model is a port of the webis/monoelectra-large model from lightning-ir to Sentence Transformers and Transformers.

The original model was introduced in the paper A Systematic Investigation of Distilling Large Language Models into Cross-Encoders for Passage Re-ranking. See https://github.com/webis-de/rank-distillm for code used to train the original model.

The model can be used as a reranker in a 2-stage "retrieve-rerank" pipeline, where it reorders passages returned by a retriever model (e.g. an embedding model or BM25) given some query. See SBERT.net Retrieve & Re-rank for more details.

Usage with Sentence Transformers

The usage is easy when you have SentenceTransformers installed.

pip install sentence-transformers

Then you can use the pre-trained model like this:

from sentence_transformers import CrossEncoder

model = CrossEncoder("cross-encoder/monoelectra-large", trust_remote_code=True)
scores = model.predict([
    ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
    ("How many people live in Berlin?", "Berlin is well known for its museums."),
])
print(scores)
# [ 6.016401  -3.6922567]

Usage with Transformers

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/monoelectra-large", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("cross-encoder/monoelectra-large")

features = tokenizer(
    [
        ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
        ("How many people live in Berlin?", "Berlin is well known for its museums."),
    ],
    padding=True,
    truncation=True,
    return_tensors="pt",
)

model.eval()
with torch.no_grad():
    scores = model(**features).logits.view(-1)
print(scores)
# tensor([ 6.0164, -3.6923])

Model info

text-ranking sentence-transformers
sentence-transformers onnx safetensors openvino electra text-classification transformers text-ranking custom_code en arxiv:2405.07920 base_model:google/electra-large-discriminator
↓ 16 ♥ 3

Created: 2025-03-31

Updated: 2025-04-15

View on Hugging Face

Files (22)

.gitattributes
README.md
config.json
model.safetensors
modeling.py
onnx/model.onnx ONNX
onnx/model_O1.onnx ONNX
onnx/model_O2.onnx ONNX
onnx/model_O3.onnx ONNX
onnx/model_O4.onnx ONNX
onnx/model_qint8_arm64.onnx ONNX
onnx/model_qint8_avx512.onnx ONNX
onnx/model_qint8_avx512_vnni.onnx ONNX
onnx/model_quint8_avx2.onnx ONNX
openvino/openvino_model.bin
openvino/openvino_model.xml
openvino/openvino_model_qint8_quantized.bin
openvino/openvino_model_qint8_quantized.xml
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.txt

Related models